fpiantini / testi18n

A sample program to learn and test the I18N python library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

testi18n

A sample program to learn and test the I18N python library, using babel with integration with Distutils/Setuptools

Prerequirements:

pip install babel

A typical workflow

  • Prepare your program to take into account I18N (see source file as an example)

  • extract the translatable objects to generate the portable objects template:

python setup.py extract_messages
  • Prepare the portable object for a new language starting from template:
python setup.py init_catalog --locale <language>
  • Edit the portable object file testi18n/locale/<language>/messages.po completing the empty or fuzzy msgstr fields.

  • Compile the portable object files:

    • Single language:
python setup.py compile_catalog --locale <language>
  • All languages:
python setup.py compile_catalog

First run of this demo

Portable object for US english and italian already available.

  • Compile the portable object files for the available languages:
python setup.py compile_catalog --locale en_US
python setup.py compile_catalog --locale it_IT
  • Run the program:
python testi18n/testi18n.py

Add translatable object

If the source files are modified and strings are added or modified, the template can be updated with the usual extract command:

python setup.py extract_messages

After this the existing portable object files can be updated using the update command:

python setup.py update_catalog

After this the po files shall be updated to translate the new strings (fuzzy translations are provided).

TODO

  • To understand if there is a better way to update language for classes or subpackages (see comments in trclass.py).

About

A sample program to learn and test the I18N python library

License:MIT License


Languages

Language:Python 100.0%