6.25.3.2 Localizing your application

If you are localizing your application, you can install the _() function globally into the built-in namespace, usually in the main driver file of your application. This will let all your application-specific files just use _('...') without having to explicitly install it in each file.

In the simple case then, you need only add the following bit of code to the main driver file of your application:

import gettext
gettext.install('myapplication')

If you need to set the locale directory or the unicode flag, you can pass these into the install() function:

import gettext
gettext.install('myapplication', '/usr/share/locale', unicode=1)

See About this document... for information on suggesting changes.