gettext.install()

gettext.install(domain, localedir=None, codeset=None, names=None)

This installs the function _() in Python’s builtins namespace, based on domain, localedir, and codeset which are passed to the function translation().

For the names parameter, please see the description of the translation object’s install() method.

As seen below, you usually mark the strings in your application that are candidates for translation, by wrapping them in a call to the _() function, like this:

print(_('This string will be translated.'))

For convenience, you want the _() function to be installed in Python’s builtins namespace, so it is easily accessible in all modules of your application.

doc_python
2016-10-07 17:33:34
Comments
Leave a Comment

Please login to continue.