[EuroPython] i18n and realted issues

Magnus Lyckå magnus@thinkware.se
Tue, 29 Apr 2003 16:43:32 +0200

A subject which is typically ignored in python books, and very relevant
in a python business perspective is localization and internationalization.

Honestly, I haven't tried very hard, but this seems a bit confusing for
me in Python. (Not that I can say that it's better in other languages.)

Is is just me, or do others feel the same?

How important is this to people, and what could be done about it? Something
to discuss at Europython 2003? (Are there plans for any BoFs etc.)

This field contains a number of issues, from translation of messages to
input and output of data formatted according to locale, and issues like
Unicode and right-to-left text etc. It seems to me that this is far from
ideal today. At least in Windows 2000, locale seems buggy:

 >>> locale.getdefaultlocale()
('sv_SE', 'cp1252')
 >>> locale.setlocale(locale.LC_ALL, '')
 >>> locale.getlocale()
['Swedish_Sweden', '1252']

You see, they aren't the same! This leads to:

 >>> locale.resetlocale()
Error: locale setting not supported

Also, the example from the manual breaks:
 >>> locale.setlocale(locale.LC_ALL, 'de')
Error: locale setting not supported

Also note, that "some string".decode(locale.getlocale()[1]) won't work
in Windows, but "some string".decode(locale.getdefaultlocale()[1])
will work. There is no code page called just '1252'. Certainly confusing
and non-obvious to me. Not fun if we try to use non-default settings.

How do we display dates and times according to locale? Does the new
date module handle that? locale.atof and locale.format can at least
display floats right. (I think.)

To the extent that the code is there, it's just briefly described in the
docs, and very little in all the Python books out there. Is this really
such a peripheral issue?

What about unicode and locale. They don't seem to get along extremely
well today... For instance is seems x.sort(locale.strcoll) can't handle
Unicode strings. Ok, in cas of doubt, refuse the temptation to guess. No
one locale defines collation for all of unicode, but there will be more
and more cases where we want to sort names from all over the world, with
at least accents in place. How?

locale.nl_langinfo is only available on some platforms... Etc etc.

Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The shortest path from thought to working program