[Sugar-devel] forcing a specific language translation

Erik Blankinship erikb at mediamods.com
Wed Dec 7 14:09:02 EST 2011


Normally, I use something like this to automatically get translations
from the right .mo file

from gettext import gettext

def _( s ):
    return gettext( s )

But what if I want to force my activity to run in a different
language?  (e.g. Swedish Chef Cookbook Activity)

I tried this:

import gettext
force_lang = gettext.translation('SwedishChef', languages=['sv'] )
force_lang.install( )

def _( s ):
    return force_lang.gettext( s )

But it did not work and I get back the default strings from my python
code instead.

Any suggestions?  Thanks!

Erik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20111207/c8bba3f6/attachment-0001.html>


More information about the Sugar-devel mailing list