mandag den 4. maj 2009

Python setlocale on Windows XP

In a development project we had some problems with guessing the correct locale string on Windows XP, and there seems to be no copy'n'paste solution on the web, so here it is:


# Import sys packages.
import locale
import os


local = 'da_DK' # Danish locale unix: 'da_DK'
if os.name is "nt":
    local = "Danish_Denmark"
# Danish locale on Windows: "Danish_Denmark" or "Danish"




 

locale.setlocale(locale.LC_ALL, local)


See the following links for inspiration on how to guess your locale:

http://msdn.microsoft.com/en-us/library/hzz3tw78(VS.80).aspx 

http://msdn.microsoft.com/en-us/library/39cwe7zf(VS.80).aspx

Ingen kommentarer:

Send en kommentar