Portable locale usage
sinisa.segvic at fer.hr
Tue Sep 6 11:59:07 CEST 2011
I am musing on how to write portable Python3 code which would
take advantage of the standard locale module.
For instance, it would be very nice if we could say something like:
# does not work!
Up to now, I have found ways to set locale on Linux and Windows:
locale.setlocale(locale.LC_ALL, 'hr_HR.utf8') # works on linux
locale.setlocale(locale.LC_ALL, 'hrv_HRV.1250') # works on windows
I have noticed that locale defines a dictionary locale.locale_alias,
and that it contains the following promising keys: 'hr_hr',
Unfortunately, both on Windows and Linux all these keys
are bound to the same outdated string 'hr_HR.ISO8859-2'.
My questions are the following:
1. Is there a way for writing portable Python code dealing with
(as sketched in the beginning)?
2. If not, is there anything wrong with that idea?
3. What is the status of locale.locale_alias (official documentation
does not mention it)?
More information about the Python-list