gettext.gettext()
gettext.gettext() is a Python function in the Gettext Module category. Returns the translated version of a message (alias _()). The syntax is gettext.gettext(message). Returns: Translated string. A typical example: import gettext
gettext.bindtextdomain("myapp", "locale")
gettext.textdomain("myapp")
gettext.gettext("Hello") # "Bonjour" (if French locale). A close sibling is gettext.translation(), which loads a translation file (.mo) and returns a GNUTranslations object. A close sibling is gettext.install(), which installs _() in Python's builtins for easy translation calls. More about this category: Internationalization — translation, find, textdomain, bindtextdomain, gettext. Related Gettext Module entries: gettext.translation(), gettext.install(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try gettext.gettext() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.