Re: how to use i18n?

Thorsten Kampe <[email protected]> Fri, 10 Sep 2004 13:07:25 +0200
Newsgroups gmane.comp.python.optik.user
Message-ID <[email protected]>
* leon breedt (2004-09-10 01:05 +0200)
> The internationalization does work, however, the gettext library needs
> to know to look for "optik.mo". I don't think its a good idea for Optik
> to implicitly set that up either [...]

It's a good idea because then /all/ the apps that use optik are
properly localised (at least to the respect of optik)

> So, here is a sample snippet of how you tell gettext to look in the 
> appropriate file:
> 
> from optik import OptionParser
> import gettext
> gettext.textdomain('optik')
> gettext.bindtextdomain('optik')
> [...] 

> You'll notice the two English messages, which is why I think you'll
> want to copy optik.de.po to myapp.de.po and change the text domain
> you bind to, so you can add your custom messages.

I found out that "gettext.textdomain('optik')" is sufficient and
"gettext.bindtextdomain('optik')" shows no effect on my box.

"textdomain" uses the "GNU gettext API" and not the "class-based API"
and therefor is "not recommended" (according to the documentation).
But anyway: it works (recommendedly or not).

So here's how I use optik and my own localisation in parallel:

import gettext
gettext.textdomain('optik')
gettext.install('myapp')

By the way: simply "gettext.install('optik')" doesn't work (don't know
why).


Thorsten



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM. 
Deadline: Sept. 13. Go here: http://sf.net/ppc_contest.php