Map Linux locale codes to Windows locale codes?

Flávio Lisbôa flisboa.costa at gmail.com
Tue Dec 14 16:00:36 EST 2010


You could look into the windows registry, the key
"HKLM\SYSTEM\CurrentControlSet\Control\Nls" has all the supported LCID's
listed. If not, you could simply get the codepage provided by
locale.setlocale(), e.g.:

import locale
print(locale.setlocale(locale.LC_ALL, ""))

prints "Portuguese_Brazil.1252" for me. That codepage part is actually a
LCID, that you can then cross-reference with any LCID list on the net. I
guess there may be a way to look that up entirely from the registry,
including getting a short reference or ANSI codepage from the LCID, but i
doubt it'd be portable at all.

Maybe what you should do is to make up a dict with known LCID's and their
corresponding language codes. I don't know of any way to do this
automatically in python...

Take a look at http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx

2010/12/14 <python at bdurham.com>

> Is there a way to map Linux locale codes to Windows locale codes?
>
> Windows has locale codes like 'Spanish_Mexico'. We would like to use the
> more ISO compliant 'es_MX' locale format under Windows.
>
> Is there a resource or API that might help us with this mapping?
>
> Babel is not an option for us since we're using Python 2.7.
>
> Thank you,
> Malcolm
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101214/cef37b8c/attachment-0001.html>


More information about the Python-list mailing list