Localizing the ApplicationΒΆ

The following steps are required to localize the application:

  1. Run find nose -name "*.py" | xgettext -f - in the application’s main directory. A file named messages.po should be created.
  2. Run msginit -l LL -i messages.po, where LL is the target locale (e.g. de or de_DE for German). Answer the questions. A file named LL.po should be created.
  3. Translate the messages in LL.po.
  4. Run msgfmt -cv LL.po -o nose.mo. A file named nose.mo should be created.
  5. Move nose.mo to resources/messages/LL/LC_MESSAGES/.
  6. Rejoice.

The contents of some translatable messages require special handling:

  • Some messages contain formatting specifiers such as %s or %(totalTimeLeft)s. These will be replaced by appropriate parameters when the application uses the string. Their respective functions should be discernible from context. Note that keywords such as the totalTimeLeft above must not be translated. msgfmt will check that these specifiers aren’t broken during translation, and will terminate with an error message if they are.
  • Some messages contain tags that may look like HTML (<i> and <sup>). These are actually Pango Markup Language tags. Breaking them will trigger a PangoWarning when the application uses them. The message in question will not be shown at all, or will be replaced with another message used nearby. In messages that don’t already have such tags, added tags almost certainly won’t be interpreted.
  • Some messages define keyboard accelerators (e.g. <Shift><Ctrl>C). These can safely be changed to whatever accelerator makes sense in the target language. Breaking them will trigger a GtkWarning when the application uses them. The message containing the text of the menu item they are used on should immediately precede the message defining the accelerator.
  • Some messages contain underscores. These define the next character as a mnemonic. These mnemonics can safely be shifted to other letters. Mnemonics defined significant distances from each other may be used in the same window, however, so special care must be taken to ensure that no character is used as a mnemonic more than once in any single window. If a mnemonic is used on several widgets in the same window, using it will select each of the widgets in sequence.
  • One message, {{MIN_CAPTION_LINES}}, is an abuse of gettext that allows the value of gui.calibration.charts.MIN_CAPTION_LINES to be set as part of the localization procedure. The application ties to parse the localized message as an integer and uses the result to set the constant if successful.

Previous topic

ops.calibration.leastsquare — Estimates the heating parameters

Next topic

Glossary