rox.i18n | index |
If you want your program to be translated into multiple languages you need
to do the following:
- Pass all strings that should be translated through the '_' function, eg:
print _('Hello World!')
- Create a Messages subdirectory in your application.
- Run 'pygettext *.py' to extract all the marked strings.
- Copy messages.pot as Messages/<lang>.po and edit (see ROX-Lib2's README).
- Use msgfmt to convert the .po files to .gmo files.
- In your application, use the rox.i18n.translation() function to set the _ function:
__builtins__._ = rox.i18n.translation(os.path.join(rox.app_dir, 'Messages'))
(for libraries, just do '_ ='; don't mess up the builtins)
Note that the marked strings must be fixed. If you're using formats, mark up the
format, eg:
print _('You have %d lives remaining') % lives
You might like to look at the scripts in ROX-Lib2's Messages directory for
more help.
Functions | ||
|