Hello Micheal,<br><br>I've changed LANGUAGE in the shell , it worked at the beginning and then it stopped working ...<br><span>Also os.environ.setdefault method still has no effect. I begin to wonder if it's specific to my distro (Ubuntu Breezy).
<br><br>Anyway I managed to use "translation" but if I give None for languages (or nothing) he gives back an IOError.<br><br>I'm finaly using a mix of "install" and "translation" through an exception handling
</span><span>and I can also change the language on the fly in the app</span><span>.<br>It works but it's probably not very "academic" :)<br><a href="http://www.flickr.com/photos/frenchy/117229913/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
http://www.flickr.com/photos/frenchy/117229913/</a><br><br>Thanks <br><span class="sg">francois</span></span><br><br><div><span class="gmail_quote">On 24/03/06, <b class="gmail_sendername">Michael Lange</b> <<a href="mailto:klappnase@freenet.de">
klappnase@freenet.de</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">On Thu, 23 Mar 2006 23:58:58 +0100<br>"francois schnell" <
<a href="mailto:francois.schnell@gmail.com">francois.schnell@gmail.com</a>> wrote:<br><br>><br>> Now I'd like to be able to change language without loging out, change<br>> language, log in.<br>><br>> Martelli says in his book that to set the default language for the app I
<br>> just need to do:<br>><br>> >>> os.environ.setdefault('LANG', 'fr_FR')<br>><br>> and Python doesn't complain (but doesn't work) but if I then do:<br>><br>> >>> print locale.getdefaultlocale
()<br>><br>> Python says : ('en_GB', 'utf-8') # meaning that really couldn't work ?<br>><br>> How can I have my app in French even if I'm still in the GB version of<br>> Ubuntu (change the language for the app) ?
<br>><br><br>Hi Francois,<br><br>I tried to do so with one of my apps (on Mandrake) and found that I have to change<br>the LANGUAGE environment variable, changing LANG had no effect on this.<br>>From the python gettext docs I found:
<br><br> If languages is not given, then the following environment variables are searched: LANGUAGE, LC_ALL, LC_MESSAGES, and LANG.<br><br>So it looks like the easiest may be to do<br><br> $ LANGUAGE=en_GB<br><br>in the shell before you start your app.
<br><br>> I've also tried the "translation" way instead of the "install" way:<br>><br>> if I do:<br>> gettext.install("myapp", localedir) #it translates in French when I'm in the<br>
> French Ubuntu<br>> but if I do instead: gettext.translation("myapp", localedir,<br>> languages="fr_FR") #with the same localedir which worked before<br>> =><br>> Python complains:<br>
> " gettext.translation("myapp", localedir, languages="fr_FR")<br>> File "/usr/lib/python2.4/gettext.py", line 480, in translation<br>> raise IOError(ENOENT, 'No translation file found for domain', domain)
<br>> IOError: [Errno 2] No translation file found for domain: 'myapp' "<br>><br>> I find it strange that "install" finds it but not "translation" (for the<br>> same localedir) ?<br>>
<br><br>I admit I nevered bothered to find out how to use gettext.translation() since gettext.install()<br>works that fine for me. Maybe you should set "languages" to "fr" instead of "fr_FR" (just a guess though)?
<br><br>I hope this helps<br><br>Michael<br>_______________________________________________<br>Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">
http://mail.python.org/mailman/listinfo/tutor</a><br></blockquote></div><br>