Date, Time and Localization Modules
gettext
Provides message translation using GNU-style catalogs and translation objects. Bind a translation object to a local name instead of changing application-global translation state. Use ngettext() for plural forms; actual language rules come from a catalog. NullTranslations provides untranslated fallback behavior.
Formal Syntax & Structure
python syntaxpython
import gettextReturn Value
module
Module namespace available through import; import is a statement, not a value-returning expression.
Working Example
Example Snippetpython
from gettext import NullTranslationstranslator = NullTranslations()print(translator.gettext("Welcome"))print(translator.ngettext("one item", "many items", 2))