-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Translations
noVNC's full UI app (vnc.html) uses a fairly standard gettext based system for translations. There are some extra scripts to handle the HTML files and to convert the translations to a format easily read from Javascript.
Strings that need to be translated are marked by wrapping them in the function _()
. E.g.:
document.getElementById('textElement').innerHTML = _("Some text");
Remember to only mark literals, not variables or expressions.
Then function _()
is an alias for Localizer.get()
. New modules need to set up this alias by doing:
var _ = Localizer.get;
Just remember to avoid putting this in the global scope.
Every visible string in the HTML files is translated by default. The attribute translate
can be set to no
to prevent translations. This attribute is inherited so if you wish to translate just a single child element then you need to specify translate="yes"
on that child.
Updating the translations is done as part of the release procedure and is done after a "string freeze". However for testing you might want to do it earlier.
This work requires some extra Javascript modules. Install this by running npm install
in the root noVNC directory. The gettext suite of tools also needs to be installed.
The first step is scanning the project and updating the template:
make -C po update-pot
This will re-generate the template file po/noVNC.pot
.
Next the individual translation files will be updated by running the command:
make -C po update-po
This will merge all .po
files with the new changes in noVNC.pot
.
The code cannot use the .po
files as they are, so they need to be converted to a Javascript representation:
make -C po update-js
Play around as needed, but avoid committing anything that would otherwise be done as part of the release procedure.
A new language is added by doing:
cd po
msginit --locale=fr_FR.UTF-8
Make sure that .UTF-8
is included in the locale string to avoid issues with character encodings.
Next, edit po/Makefile
and app/ui.js
to update the LINGUAS
variables. Try to keep these lists alphabetically ordered. Note that the locale name has been normalised by msginit
so pay attention to what it actually generated.
Finally fill in the new .po
the same way as an existing translation would be handled.