-
Notifications
You must be signed in to change notification settings - Fork 35
Internationalization
- Internationalization is the process of designing software so that it can be adapted to various languages and regions without engineering changes. Localization is the process of adapting software for a specific region or language by adding locale-specific components and translating text.
For developers:
The GNU gettext system is used. All text fragments are called in the code like this:
GT._("Here the English text")
- Special case:
- When the text includes a variable word or phrase that comes from an external source (somewhere else in the code, which changes depending on the current situation), you should account for it in this way:
GT._("Here the number {0} English text",someVariable)
- The value of someVariable will be inserted at the position of {0}, so it might render, e.g., as
- Here the number 1 English text
- Here the number 2 English text
- etc.
- This is needed since the position of that word may be different in different languages. Translators should leave the {0} token as is but put it in the proper place. For example, Spanish translation would be:
"Aquí va el texto en español número {0}"
- Aquí va el texto en español número 1
- Aquí va el texto en español número 2
- etc.
- If more than one such words are needed, use {0}, {1}, etc., and the code changes a little bit, like in:
GT._("The user {0} has an id of {1} for this session.", new String[]{ userName,sessID })
Note that the menus are built from properties files. Therefore there must be an entry in org.openscience.jchempaint.JCPMenuTextMaker for them to be recognized by gettext.
The pot
file is generated by calling
xgettext -kGT._ -o po/keys.pot $(find src/main -name "*.java")
For each locale, a po
file is made by
msgmerge -U po/de.po po/keys.pot
Note that the ant task "build-pot-pos" does both these steps. If a new language is to be added, the msgmerge needs to be run manually for that language once.
The *.po files then need to be edited. See instructions for starting a new translation and for updating existing translations. You can also use launchpad for translations. Note that launchpad and svn must be synchronized manually.
The people responsible for the locales are:
- Arabic - Abdellah Chelli
- Catalan - Carlos Giménez, Ángel Lucas
- Chinese - Yun Wang
- Czech - Martin Slavík
- Dutch - Egon Willighagen
- English - is in code
- German - Stefan Kuhn
- Hungarian - Muszela Balázs
- Norwegian Bokmal - Svein Olav Hagen
- Polish - Nikodem Miranowicz
- Portuguese-Brazilian - Ricardo Stefani
- Russian - Konstantin Tokarev
- Spanish - Angel Herráez
- Thai - Thammaraj
po
files are ready , the ResourceBundle class files are made by
msgfmt --java2 -d po/classes -r app.i18n.Messages -l de po/de.po
This is also performed by the ant target "build-languageclasses", which is called when distributions are done. So there should be no need for manual interaction with respect to ResourceBundle classes.
Help Pages (shown via Help menu in JCP) can be tranlated as well, but this does not use GNU gettext. The package org.openscience.jchempaint.resources.userhelp_jcp can contain a subpackage for each language code. If none is there, fallback is to English.
The help pages can be downloaded via this tar file or checked out from git.