Skip to content

Translations

The UI uses a simple JSON file format to handle translations. The JSON format is described by the Transifex JSON format documentation page.

Translators have to access Transifex to localize the messages.

Developers have to follow the rules described by the next section.

See also the Internationalization section in the Developer manual.

Developer rules

The source code repository must have the messages source strings already localized in English (US) and saved according the above JSON format.

The JSON source code path, depends on many factors. A typical example for simple projects could be <project root>/ui/i18n/language.json, whilst a Vue.js project can use <project root>/ui/public/i18n/language.json.

The resulting runtime URL, relative to the application base URL must be ./i18n/language.json. That URL is required by the nethserver.fetchTranslatedStrings() method. To obtain this, the application RPM must install the language.json source catalog as /usr/share/cockpit/<APPDIR>/i18n/language.json.

For instance <APPDIR> can be nethserver-myapp.

Prerequisites

  • create a personal Transifex account associated to the nethserver organization
  • install the Transifex Client (command tx)
  • ensure the repository root dir has a .tx/config file

For instance, for the "MyApp" application .tx/config must have something like:

[nethserver.CockpitMyApp]
source_file = ui/i18n/language.json
source_lang = en
type = KEYVALUEJSON

Note the mandatory nethserver.Cockpit* prefix for the strings catalog "slug" name.

Simple workflow

  1. When a new string in source code has to be translated, add it to the language.json file,

  2. Commit changes to git

  3. When the changes are ready for the release send the strings to Transifex for the translation by running tx push -s in the repository root directory

Translations packages

The localized strings are periodically downloaded from Transifex and added to the nethserver-lang repository. They are packed in separate RPMs at a later time.

The UI application developer must list his JSON traslation files in nethserver-lang/.tx/config; following the example above, the corresponding resource specification is:

[nethserver.CockpitMail]
file_filter = ui/nethserver-myapp/language.<lang>.json
source_file = ui/nethserver-myapp/language.json
source_lang = en
type = KEYVALUEJSON

The developer can open a Pull Request to merge his code in nethserver-lang.

Translations API

See the "UI guidelines" section.