Translations
Copy as MarkdownThe web console's texts are JSON files, one per language, in neodesk-server/console/static/files/lang. There are 26 of them, from ar.json to zh-TW.json. They are built into the server binary, so a changed text reaches users with the next release.
How the files work
Each file is one JSON object with nested sections, such as common, devices or settings. The console asks for a text by its path, for example devices.title.
en.jsonandpl.jsonare the reference languages. Their keys together are the baseline that every other file is checked against.- The server lays a language over the default language, English unless
DEFAULT_LANGUAGEnames another, so a key a language lacks shows the default language's text. {count},{name}and the like are placeholders that the console fills in. Keep them exactly as they are.- The
metasection names the language:lang(its code),name(in English) andnative_name(in the language itself). A file can carry a_metasection instead, which wins when present and can also holdflag,rtlandneeds_review.
{
"meta": {
"lang": "de",
"name": "German",
"native_name": "Deutsch"
},
"common": {
"loading": "Laden...",
"save": "Speichern"
}
}Right to left: Arabic and Hebrew are marked as right-to-left languages in the server's table of languages (see Add a language). "rtl": true in a file's _meta section marks any other language.
Improve a translation
- Edit
neodesk-server/console/static/files/lang/<code>.json. - Change only the values, never the keys.
- Keep the placeholders, and use HTML only where the English text has it.
- Translate a text or leave it out. Don't copy the English text into another language to fill a gap: the check counts such values as untranslated, and the gap stays hidden.
- Run the check below and open a pull request, see Contributing.
"needs_review": true in _meta shows the language as Needs review on the console's Translations page.
Add a language
The server loads only the languages in its table, knownLanguages in neodesk-server/console/i18n/bundle.go. A file whose code is not in the table is never loaded. So a new language takes a small code change:
- Add a row to the table: the code, the English name, the native name, the flag and whether it is written right to left. The code is two to eight lower-case letters, with an optional region such as
-TW. - Copy
en.jsonto<code>.json, set itsmetasection, and translate every value. - For a flag in the language menu, add
web-ui/static/img/flags/<code>.svgand the code to the list inweb-ui/src/lib/ui/LangFlag.svelte. A language without a flag shows its name only.
Hebrew (he) is in the table but has no file yet.
Add a text to the console
For developers. A text the web app shows comes from a key: t('devices.title'), or tf('devices.title', 'Devices') with an English fallback. The fallback shows only when the loaded language files lack the key, so keep it the same as the text in en.json. Lint rejects text written directly into the markup.
A new key goes into every language file, not only en.json: the check fails when any file misses a baseline key. Give each language a real translation. web-ui/README.md has the web app's text rules.
Check your work
In neodesk-server:
go run ./cmd/repotool i18n-check --system consoleThe check fails when:
- a file does not parse;
- a file misses a key of the baseline;
- a value is empty;
en.jsonandpl.jsondon't have the same keys.
It reports, without failing, keys a file has that the baseline doesn't, and values in another language that are still the English text. --verbose lists those, and --json prints the whole result as JSON. The check never changes a file; there is no option that fills gaps with English.
Go Server CI and the local gate run it, and Secret Scan checks the pairing texts separately with check-pairing-i18n.
See it in the console
A server you build yourself carries your files, see Building from source. To try changes without building again, start the server with CONSOLE_LANG_DIR set to your lang folder: it then reads the language files from disk. It reads them when it starts, so restart it after a change.
The console's Translations page (/languages, for accounts with the Server configuration permission) shows how complete each language is, with its status and the number of missing texts. Show texts lists every text of a language next to the English one. The page only reads; texts are changed in the files.