Home

understanding_i18n

Updated:
Created:

if I travel the world, so should my software

Reading:

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