How-to guides

Multilingual Komods

The KOFA UI runs in Hungarian and English; the user switches the language in the header. A Komod's texts come from the package's own dictionary: the Hungarian text stays in the code, every other language is a JSON file. A text without a translation is shown in Hungarian, so everything works without a dictionary too.

Where the dictionary lives

MyKomod/i18n/en.json        texts of the server project: metadata, command errors
MyKomod.Ui/i18n/en.json     texts of the views: T("…", "…")

The build copies them to the package's i18n/ and i18n/client/ folders. The two are one namespace: a key may appear in only one of them. KOFA prefixes the keys with the package id, so the keys of two Komods never collide.

{
  "widget.release": "Release",
  "widget.items": { "one": "{count} item", "other": "{count} items" }
}
  • {name}: a placeholder. Every language must use the same ones as the Hungarian text.
  • one / other: plural forms, picked by the count argument.
  • null: the key is known but not translated yet.

Metadata

[Komod], [Input], [Output], the settings' [Description] and [DeploymentSetting(Label = …)] stay Hungarian in the code. Their translations use fixed keys:

What Key
package name / description (Package.props) package.name, package.description
Komod name / description komod.<komodId>.name, komod.<komodId>.description
port komod.<komodId>.port.<portId>.name, .description
setting ([Description]) komod.<komodId>.setting.<jsonName>
deployment setting komod.<komodId>.deploy.<jsonName>
enum value ([Description] on the member) enum.<EnumType>.<Member>

Views (UI)

<button>@T("widget.release", "Feloldás")</button>
<span>@T("widget.items", "{count} elem", ("count", _items.Count))</span>

T(key, Hungarian text, arguments) comes from KomodComponentBase. The Language property is the UI's language (e.g. en).

Command errors

throw new KomodCommandException(Text("errors.noMap", "Nincs betöltött térkép: {name}", ("name", name)));

Text(...) comes from KomodBase (or Context.Text(...)). The caller gets the message in their own language; a plain KomodCommandException("…") still works and is shown in Hungarian.

Status

Context.ReportStatus(KomodHealth.Warning, Text("status.lowBattery", "Alacsony akku: {percent}%", ("percent", 18)));

Everyone sees it in their own language on the graph node, the dashboard and the instance page. ReportStatus(health, "text") stays Hungarian.

Tools

dotnet run --project tools/Kofa.I18n -- extract komods/MyKomod
dotnet run --project tools/Kofa.I18n -- check
dotnet run --project tools/Kofa.I18n -- pseudo
  • extract: builds hu.json from the code (build the project first for the metadata) and adds the missing keys to the other languages as null.
  • check: missing and stale keys, placeholder mismatches, coverage per language.
  • pseudo: a pseudo language ([Šàṽé~~]) that shows untranslated and cut texts. It never goes into the package.

kofa-pack rejects an invalid dictionary and writes the languages into komod.json ("languages": ["en", "hu"]), shown on the Komods page.

The community can translate your Komod to further languages on the KOFA site: see Community translation.

Compatibility: KOFA versions before November 2026 refuse to install a package with a dictionary ("Ismeretlen fájl a csomagban: i18n/…").