Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Members / jhb / old blog entries / understanding_i18n

understanding_i18n

by Jörg Baach last modified Apr 27, 2007 10:53 AM
if I travel the world, so should my software

Reading:

http://docs.python.org/lib/node738.html
http://po-utils.progiciels-bpi.ca/showfile.html?name=dist/README

What do I understand:

The process of i18n (and l8n) involves a couple of steps:

decide a name for the application (e.g. myapp)

1. 'marking' string in the source as translated, most of the time using
the underscore function _
2. Collecting all the string into a translation template - *.pot (pygettext)
3. translating the files - basically copy the .pot into a .po file, and
then translating
4. converting the .po into a .mo file (msgfmt.py)
5. copy the .mo file at the proper location

locale/de/LC_MESSAGES/myapp.mo
locale/de/LC_MESSAGES/myapp.mo
locale/london/LC_MESSAGES/myapp.mo

6. In the source, do a:

import gettext
lang1 = gettext.translation('myapp', './locale',languages=['de'])
lang2 = gettext.translation('myapp', './locale',languages=['london','en'])
lang1.install()
print _('foobar')
lang2.install()
print _('foobar')

That should be it

Add comment

You can add a comment by filling out the form below. Plain text formatting.

Question: What is 23 plus 19?
Your answer: