You can provide translated messages for your model by editing
modelName.message.ini file located in the same directory where
dir /B openmpp_win_20180205\models\bin .... modelOne.exe modelOne.ini modelOne.message.ini modelOne.sqlite
modelOne.message.ini is translated messages for
Message.ini file must be UTF-8 encoded and it contain model translated messages:
; ; modelOne localized messages ; [fr] Run %d = Exécution: %d [fr-CA] ; Run %d = Exécution: %d [en] ; Model = Model
If translation the same as original message you can exclude it, e.g.:
Model = Model is not required.
How model finds translated message
At start model determine list user preferred languages. For example if current environment is French Canadian and model default language is EN then language list will be:
(fr-ca, fr, en).
User language preference can be changed in Windows Control Panel or by Linux LANG environment variable. You can override environment language by using model command-line or ini-file argument:
modelOne.exe -OpenM.MessageLanguage es-EC
To find translated message model does lookup in:
- database table
- database table
Search done in order of user preferred languages.
For example, if
modelOne.message.ini is same as above and database table
model_word contains entry:
fr-CA Done. Fini.
Then model messages in French Canadian environment can be similar to:
2014-03-17 17:14:24.0023 Model: modelOne 2014-03-17 17:14:24.0070 Exécution 101 .... 2014-03-17 17:14:24.0179 Fini.
As you can see for current user language
fr-CA model found two messages translated in "generic
fr" French: "Exécution" and "Fini", however "Model" still untranslated. To fix this you can update
modelOne.message.ini by adding:
[fr-CA] Model = Modèle
Then result would look like:
2014-03-17 17:14:24.0023 Modèle: modelOne 2014-03-17 17:14:24.0070 Exécution 101 .... 2014-03-17 17:14:24.0179 Fini.
Model developer: How to mark strings for translation in model code
Omc model compiler automatically include first
"const char *" argument of
theLog->logFormatted("some format %d %g %s",....);
model.message.ini file, which can be used as translation starting point.
If your source code directory already contains translated
code/model.message.ini then such file is merged with newly added model messages into output
bin/model.message.ini, which you can forward to translation team.
It is possible to use macro LT("something") in order to build concatenated message, however LT is "strictly inline" because it returns temporary "const char *" pointer. As result following will crash your model:
const char * myBadDay = LT("nice day"); if (myBadDay .... // memory access violation, model crash
Also string concatenation considered as bad practice by any translation guide.
<metadesc>OpenM++: open source microsimulation platform</metadesc>