python-gettext is a Python library and command-line tool designed to compile Gettext `.po` (Portable Object) files into `.mo` (Machine Object) files. These `.mo` files are then used by internationalization (i18n) systems for runtime message translation. The current version is 5.0, with releases typically tied to Python version compatibility or API refinements.
pip install python-gettextVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to programmatically compile a `.po` file into a `.mo` file using `gettext_compiler.compile_mo_file`. It creates a simple dummy `.po` file, compiles it, and then cleans up the generated files.
Update your import statements from `from msgfmt_compiler import ...` to `from gettext_compiler import ...`.
Ensure your project is running on Python 3.7+ to use `python-gettext` versions 4.0 and higher.
Remember that `python-gettext` provides the `gettext_compiler` module for the build-time step of creating `.mo` files, while the standard `gettext` module is used at runtime for actual message lookup.
Ensure your `.po` files are consistently encoded, preferably UTF-8. If using a different encoding, you may need to pre-process the `.po` content before passing it to the compiler.
No dependency data recorded yet.