[python-win32] LOCALE related stuff Re: Setting environment variables in windows from Python Programs-

Nalli Dinesh nalli.dinesh at gmail.com
Wed May 11 21:31:05 CEST 2005


There is no space between the quotes in locale.setlocale(locale.LC_ALL, '').
And I tried setting the Variable like the way u suggested:
>    import os
>    os.environ['LANG'] = 'ja_JP'
>    import locale
>    locale.setlocale(locale.LC_ALL, '')
>    import sys
>    import pygtk

It doesn;t change my state of my appliation. I don;tknow where the
issue lies now. I print LANG environment everywhere in the code and it
does say the LANG is set by os.environ. But setlocale is not
understaning this. But remmember, Python2.3.5 works fine with setting
env LANG set within the code.

On 5/11/05, Tim Roberts <timr at probo.com> wrote:
> Nalli Dinesh wrote:
> 
> >I using locale.setlocale and u guys know when we use this setlocale.
> >Yes I am working on Localising my application-a pygtk application.
> >When one says
> >import locale
> >locale.setlocale(locale.LC_ALL, ' ')
> >
> >
> 
> You don't really have a blank space between those quotes, do you?
> 
> >This sets the locale for all categories to the user's default setting
> >(typically specified in the LANG environment variable).
> >I use Python2.4
> >Before I start my application from the DOS command prompt, run this
> >command at the cmd prompt to set LANG environment. Which is "set
> >LANG=ja_JP"
> >And now if I run my python(that uses pygtk ) application it starts up
> >and locale.setlocale able to read this LANG variable and do the needed
> >setting for the locale.
> >But if I don;t define this variable at the command prompt before I
> >start the python application, but I define the environmen variable
> >LANG like os.environ['LANG'] = 'ja_JP'.
> >Then the setlocale doesn't set the locale as needed.
> >
> >
> 
> When do you set the variable?  It must be before ANY import that might
> read the locale.  So, for example, the first lines of your file might
> need to be:
>    import os
>    os.environ['LANG'] = 'ja_JP'
>    import locale
>    locale.setlocale(locale.LC_ALL, '')
>    import sys
>    import pygtk
>    ...
> 
> --
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
> 
>


More information about the Python-win32 mailing list