Python gettext: multilingual internationalization services
Answer: The gettext module provides multilingual internationalization services. The global API can change translation for the whole application. bindtextdomain binds a domain to a locale directory of binary .mo files.
Examples
import gettext
gettext.bindtextdomain('myapp', 'locales')
Notes
The global API is often what you want for a monolingual application whose language follows the user locale. The docs also describe a class-based API.
Reference list
gettextprovides multilingual internationalization services.bindtextdomainbinds a domain to a locale directory..mofiles are the binary catalogs it looks for.
See also
Claims
- id: C1 claim: gettext provides multilingual internationalization services. source: S1 evidence: "Multilingual internationalization services"
- id: C2 claim: The global API can change translation for the whole application. source: S1 evidence: "you will affect the translation of your entire application globally"
- id: C3 claim: bindtextdomain binds a domain to a locale directory. source: S2 evidence: "Bind the domain to the locale directory localedir"
Sources
- [S1] gettext — Multilingual internationalization services. Python docs. https://docs.python.org/3/library/gettext.html . License: PSF-2.0. Accessed 2026-11-18.
- [S2] gettext.rst. CPython docs. https://raw.githubusercontent.com/python/cpython/main/Doc/library/gettext.rst . License: PSF-2.0. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python docs, gettext — Multilingual internationalization services; CPython docs, gettext.rst. PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python docs, gettext — Multilingual internationalization services; CPython docs, gettext.rst. PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.
Cite this
iinventedlight. 2026. "Python gettext: multilingual internationalization services." iinventedlight Library, iil:note:j41se7pr, version of 2026-11-18. https://iinventedlight.com/library/notes/python-gettext/. License: CC-BY-4.0.
@misc{iil_note_j41se7pr,
author = {{iinventedlight}},
title = {{Python gettext: multilingual internationalization services}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/python-gettext/},
note = {Permanent ID iil:note:j41se7pr. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-gettext.table.json (table; CC-BY-4.0)
- python-gettext.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-gettext.md.