Translation library for Python
pip install python-i18npython-i18n

This library provides i18n functionality for Python 3 out of the box. The usage is mostly based on Rails i18n library.
Installation
Just run
pip install python-i18n
If you want to use YAML to store your translations, use
pip install python-i18n[YAML]
Usage
Basic usage
The simplest, though not very useful usage would be
import i18n
i18n.add_translation('foo', 'bar')
i18n.t('foo') # bar
Using translation files
YAML and JSON formats are supported to store translations. With the default configuration, if you have the following foo.en.yml file
en:
hi: Hello world !
in /path/to/translations folder, you simply need to add the folder to the translations path.
import i18n
i18n.load_path.append('/path/to/translations')
i18n.t('foo.hi') # Hello world !
Please note that YAML format is used as default file format if you have yaml module installed.
If both yaml and json modules available and you want to use JSON to store translations, explicitly specify that: i18n.set('file_format', 'json')
Memoization
Setting the configuration value enable_memoization in the settings dir will load the files from disk the first time they
are loaded and then store their content in memory. On the next use the file content will be provided from memory and not
loaded from disk, preventing disk access. While this can be useful in some contexts, keep in mind there is no current way of
issuing a command to the reloader to re-read the files from disk, so if you are updating your translation file without restarting
the interpreter do not use this option.
Namespaces
File namespaces
In the above example, the translation key is foo.hi and not just . This is because the translation filename format is by default , so the {namespace} part of the file is used as translation.