python-i18n is an easy-to-use internationalization (i18n) library for Python 3, providing functionality largely inspired by Rails i18n. It allows developers to manage translations, pluralization, and placeholders using YAML or JSON files. The current version is 0.3.9, last released in August 2020, indicating a low-activity maintenance status.
pip install python-i18nVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize `python-i18n` by adding translation file paths, setting the locale, and performing basic translations, including placeholders and pluralization. It assumes translation files (YAML or JSON) are stored in a `locales` directory.
Ensure your project runs on Python 3.x for full compatibility with the current library version.
During development, set `enable_memoization` to `False` or restart your application after modifying translation files. For production, enabling it can improve performance, but requires a deployment strategy that handles application restarts for translation updates.
Either adjust your translation keys to include the filename namespace (e.g., `i18n.t('filename.key')`) or explicitly set `i18n.set('filename_format', '{locale}.{format}')` to remove the filename prefix from keys.If you prefer JSON files over YAML when both are possible, explicitly set `i18n.set('file_format', 'json')` before loading translation paths.No resource links recorded.