*Here is a solution. *
import gettext
import os
#I suppose we ought use the activity directory here
force_lang = gettext.translation('SwedishChef',
localedir=os.path.join(os.getcwd(), 'locale'), languages=['sv'] )
force_lang.install( )
def _( s ):
return force_lang.gettext( s )
On Wed, Dec 7, 2011 at 2:09 PM, Erik Blankinship wrote:
> 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
>
>
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel