Posts

Showing posts with the label python

localization in python

  mkdir locales  mkdir en  mkdir LC_MESSAGES    $ tree locales/ locales/ ├── base.pot ├── en │   └── LC_MESSAGES │       └── base.po └── ta     └── LC_MESSAGES         ├── base.mo         └── base.po  $ cat gettextExample.py  import gettext _ = gettext.gettext def print_some_strings():     print(_("Hello world"))     print(_("This is a translatable string")) if __name__ == '__main__':     print_some_strings() pot file:  $ pygettext3.py -d  base -o locales/base.pot gettextExample.py   po file:    $ cp ~/pythonScripts/locales/base.pot base.po    $ cat locales/ta/LC_MESSAGES/base.po # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR ORGANIZATION # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "POT-Creation-Date: 2022-04-22 08:47-0500\n" "PO-Revision-Date: ...