Localization - set to default on Windows
durumdara
durumdara at gmail.com
Fri Nov 10 04:26:43 EST 2006
Hi !
I want to set default locale on WXP.
I want to create a formatting tool that can set up format locale in the
init, and next the formatter functions are use these settings.
Example:
fmtunit:
-------
SetLocaleToDefault()
def ToUnicode(text, encoding = None):
....
if encoding == None:
encoding = defaultencoding
...
This is my test code that have been failed in more point.
import locale
# Get default
print locale.getdefaultlocale('LANG')
# Get actual
print locale.getlocale(locale.LC_ALL)
# Get default to "loc"
loc, enc = locale.getdefaultlocale('LANG')
try:
# Try to set
locale.setlocale(locale.LC_ALL, loc)
except Exception, msg:
# An error
print msg
# Get actual
print locale.getlocale(locale.LC_ALL)
# Set manually
locale.setlocale(locale.LC_ALL, "HU")
# Get the actual locale
print locale.getlocale(locale.LC_ALL)
print locale.getdefaultlocale('LANG')
The result was:
> Executing: C:\Program Files\ConTEXT\ConExec.exe
"c:\python24\python" "c:\loc.py"
('hu_HU', 'cp1250')
(None, None)
unsupported locale setting
(None, None)
('Hungarian_Hungary', '1250')
('hu_HU', 'cp1250')
> Execution finished.
Two interesting thing I see:
1. The default locale (hu_HU) is not correct parameter for setlocale.
Why ? I want to determine and set up the locale automatically,
with script !
2. When I set locale with HU, then I cannot compare default locale
with locale, to check it's state. These values are uncomparable:
"HU", "hu_HU", "Hungarian_Hungary"...
Please help me: how to do this localization ?
Thanks for it:
dd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20061110/a5919fa0/attachment.html>
More information about the Python-list
mailing list