Internationalisation (i8n) of messages

simo simoninusa2001 at yahoo.co.uk
Wed Mar 31 17:20:09 EST 2004


I've just externalised the messages in my program and was thinking
about internationalisation.

I could probably translate my messages to French and German, and a
friend could do Spanish. I was also thinking of date formats - as a
Brit, I can't get used to the awful American MM/DD/YY format ;o) I
don't think I'll be needing currency or decimal (. or ,) info.

I was basically thinking of doing something like:

import locale
self.locale_array = locale.getlocale()
self.language = self.locale_array[0]

if self.language == "en_GB":
  self.dateformat = "DD/MM/YYYY"
elif self.language == "de_DE":
  self.dateformat = "DD-MM-YYYY"
else:
  self.dateformat = "MM/DD/YY"

So if getlocale returns None, None (like on my Sparc) then it defaults
to US English, otherwise it does UK English or German.

The problem is that the languages I've come across seem to differ
widely between Solaris/py2.3.2, Linux/py2.2.2 and Windows/py2.3.3 (all
I've tested), I was thinking of doing a case-insensitive grep, but
that seems hacky.

The Python 2.3 locale documentation seems crappy, just a bit of info
about POSIX locale.

Any ideas of how I can do this or better documentation URLs? I'm using
wxPython for my GUI, in case that provides some i8n support....?



More information about the Python-list mailing list