GNU Info

Info Node: (python2.1-lib.info)Localizing your module

(python2.1-lib.info)Localizing your module


Next: Localizing your application Prev: Internationalizing your programs and modules Up: Internationalizing your programs and modules
Enter node , (file) or (file)node

Localizing your module
......................

If you are localizing your module, you must take care not to make
global changes, e.g. to the built-in namespace.  You should not use the
GNU `gettext' API but instead the class-based API.

Let's say your module is called "spam" and the module's various natural
language translation `.mo' files reside in `/usr/share/locale' in GNU
`gettext' format.  Here's what you would put at the top of your module:

     import gettext
     t = gettext.translation('spam', '/usr/share/locale')
     _ = t.gettext

If your translators were providing you with Unicode strings in their
`.po' files, you'd instead do:

     import gettext
     t = gettext.translation('spam', '/usr/share/locale')
     _ = t.ugettext


automatically generated by info2www version 1.2.2.9