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 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:

Ingen kommentarer:

Send en kommentar