Skip to content

Translations Guide

All text and numerical content in widgets should be translated and localized. English is the default language, and other locales are maintained directly in public/locales.

Daemun uses i18next with react-i18next to handle translations. These libraries provide hooks and utilities to help you localize your widgets.

import { useTranslation } from "react-i18next";
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
export default function Component() {
const { t } = useTranslation();
return (
<Container service={service}>
<Block label="yourwidget.key1" />
<Block label="yourwidget.key2" />
<Block label="yourwidget.key3" />
</Container>
);
}

Daemun uses translated and localized strings for all text and numerical content in widgets. To add the English translations for your widget, follow these steps:

Open the public/locales/en/common.json file.

Add a new object for your widget to the bottom of the list, like this:

"yourwidget": {
"key1": "Value 1",
"key2": "Value 2",
"key3": "Value 3"
}

Daemun provides a set of common translations that you can use in your widgets. These translations are used to format numerical content, dates, and other common elements.

KeyTranslationDescription
common.bytes1,000 BFormat a number in bytes.
common.bits1,000 bitFormat a number in bits.
common.bbytes1 KiBFormat a number in binary bytes.
common.bbits1 KibitFormat a number in binary bits.
common.byterate1,000 B/sFormat a byte rate.
common.bibyterate1 KiB/sFormat a binary byte rate.
common.bitrate1,000 bit/sFormat a bit rate.
common.bibitrate1 Kibit/sFormat a binary bit rate.
common.percent50%Format a percentage.
common.number1,000Format a number.
common.ms1,000 msFormat a number in milliseconds.
common.date2024-01-01Format a date.
common.relativeDate1 day agoFormat a relative date.
common.duration1 day, 1 hourFormat an duration.
KeyTranslationDescription
resources.cpuCPUCPU usage.
resources.memMEMMemory usage.
resources.totalTotalTotal resource.
resources.freeFreeFree resource.
resources.usedUsedUsed resource.
resources.loadLoadLoad value.
resources.tempTEMPTemperature value.
resources.maxMaxMaximum value.
resources.uptimeUPUptime.