Translation assistant

The translation assistant can be opened from the dialog boxes by hiting the F2 function key. It makes it possible to create and change the translation lexicons of the application in .properties files. Capsis handles french (_fr) and english (_en).

The concerned dialogs are the Capsis dialogs, the dialogs of the modules and of the extensions. The technical dialogs like the Java FileChooser are not concerned.

The .properties files can be of different kinds, all the paths below are relative to capsis4/bin/ :

- capsis/Labels_en.properties (and _fr) : the two files for the interactive pilot of Capsis.
- pp3/Pp3Labels_en.properties (and _fr) : the translation files for the Capsis modules (forestry growth and yield / dynamics models), here example for PP3, two files per module.
- capsis/extension/intervener/DHAThinner_en.properties (and _fr) : the translation files for the Capsis interactive extensions, here example for the intervener "Diameter Height Age", two files per extension.

The translation assistant is a 3 columns table. The first column contains the keys used in the Java source code of the dialog box. The two other columns show respectively the translations in french and in english of these keys, as they are known by the Capsis Translator (class Capsis.util.Translator).

Above the table, there is a list of names of the lexicons that contain the translations (or that should contain them if the english column is empty for example), each lexicon matches two translation files, french and english. For example, le lexicon alisier.AlsLabels matches the two files alisier/AlsLabels_fr.properties and alisier/AlsLabels_en.properties.

When a lexicon is checked, the keys inside become editable and it is possible to change their meaning directly in the table.

Once the changes done, the Save button alters the concerned .properties files and reloads them in the Capsis Translator. The changes will be visible at the next dialog opening.

Choice of the lexicon for writing the translations

The list of keys in the first column is made by reading the source code of the dialog box. This way, we are sure that the list in complete (technical note: looking for the keys used in "Translator.swap" occurrences). The translations in the two other columns are obtained by asking the Translator.

The keys which translation is just modified are writen back in the lexicon where they were found (by asking the Translator).

If a translation is not found (in no .properties file), the matching table cell is let empty and the Translator can not give the source lexicon of the key. To find a lexicon for the keys without translations, we process in order this way:

(1) look for a direct reference to the lexicon in the source code (technical note: by searching the instruction "Translator.addBundle"),
(2) considering the class prefix, look for a key with a known translation and which lexicon has the same prefix (e.g.: alisier.gui.DInitStand / alisier.AlsLabels), use this lexicon,
(3) hypothesize that the dialog is part of a Capsis module and try to get the id card of the module by following the ad hoc naming conventions and if found, ask it the lexicon name (by idCard.getModelBundleBaseName ()),
(4) create a lexicon from the class name and in the same directory (for the extensions for example).

Note: this detection method makes it possible to translate the keys once the Java source code writen without having to open the .properties files with an editor.

CVS note: when a lexicon is created, it must be added then commited in CVS. When a lexicon is changed, it must be commited in CVS. Take care to commit only the lexicons of your own (e.g.: your module / extensions).