You can look up available locale names on MSDN.
You have to pass the long version from "Language string" in the MSDN list as value to setlocale
. The default L10N short codes like en_EN
which are in locale_alias
do NOT work in general.
I have already extracted some of them as dictionary:
LANGUAGES = {
'bg_BG': 'Bulgarian',
'cs_CZ': 'Czech',
'da_DK': 'Danish',
'de_DE': 'German',
'el_GR': 'Greek',
'en_US': 'English',
'es_ES': 'Spanish',
'et_EE': 'Estonian',
'fi_FI': 'Finnish',
'fr_FR': 'French',
'hr_HR': 'Croatian',
'hu_HU': 'Hungarian',
'it_IT': 'Italian',
'lt_LT': 'Lithuanian',
'lv_LV': 'Latvian',
'nl_NL': 'Dutch',
'no_NO': 'Norwegian',
'pl_PL': 'Polish',
'pt_PT': 'Portuguese',
'ro_RO': 'Romanian',
'ru_RU': 'Russian',
'sk_SK': 'Slovak',
'sl_SI': 'Slovenian',
'sv_SE': 'Swedish',
'tr_TR': 'Turkish',
'zh_CN': 'Chinese',
}
[item for item in locale.locale_alias.items() if "pt_br" in item[0].lower()]
and got as a result:[('pt_br.iso88591', 'pt_BR.ISO8859-1'), ('pt_br.88591', 'pt_BR.ISO8859-1'), ('pt_br', 'pt_BR.ISO8859-1'), ('pt_br@euro', 'pt_BR.ISO8859-15'), ('pt_br.iso885915', 'pt_BR.ISO8859-15')]
- the problerm is I have a ut-f8 pt_BR locale not listed above- the following works:locale.setlocale(locale.LC_TIME, "pt_BR.utf-8")
– Balm