Extracting translatable text

The Python implementation code is never modified by the translators. Translation is accomplished by extracting the translatable text from the code files and then creating separate files containing the translated text, one file for each language. The _ function uses compiled versions of these files.

The standard Python distribution includes pygettext.py, which is a command line script that extracts strings marked as translatable (i.e., strings wrapped in the _ function) and saves them to a .pot file. Run pygettext.py on the implementation code, and specify the name of the implementing Python module (the module containing the Run function) as the name of the output file, but with the extension .pot. If the implementation uses multiple Python files, the .pot files for each should be combined into one under the name of the main implementing module (the module containing the Run function).

  • Change the charset value, in the msgstr field corresponding to msgid "", to utf-8.
  • A pot file includes one msgid field with the value "", with an associated msgstr field containing metadata. There must be only one of these.
  • Optionally, update the generated title and organization comments.

Documentation for pygettext.py is available from the topic on the gettext module in the Python help system.