Natural Language Support#
BOUT++ uses GNU gettext. to
provide translations of output strings. Configuration is described in
Natural Language Support and running in Natural language support. Currently
only fr, zh_TW, and zh_CN have been added, but it is quite
easy to add more. See locale/README.md or below.
Marking strings for translation#
In the code strings are wrapped with _() e.g. "hello world"
becomes _("hello world"). Find a string you want to replace (which
can include formatting like %d), surround it with _(). Then in
the locale directory:
make libbout.pot
will update the template file libbout.pot under
BOUT_TOP/locale. The template file should not be edited, but is
used to generate language-specific files (libbout.po).
To update these language files see the next section.
Adding translations#
Adding support for a new language, or improving the translations in the existing files can be done by:
Going to the
localeBOUT++ subdirectory and running:make locale-ll
where
llis the language code e.g.make locale-zh_TWormake locale-de. This will create a filelibbout.pounder alocale/llsubdirectory.Edit the
locale/ll/libbout.pofile. Edit the .po file in de subdirectory (not the .pot file!), adding the translations. Eachmsgidentry should have a translatedmsgstrentry. If you don’t want to translate them all, just delete the ones you don’t translate. Any missing will just revert to the version in the code. If you’re adding UTF-8 characters, change the content line in the .po file to have charset=UTF-8.In the
localedirectory runmake. This should output something like:Building language: fr Building language: zh_CN Building language: zh_TW
The new language should now be available (no need to recompile BOUT++).