In trying to get python to spit out names in specific locale I landed here with same problem.
In pursuing the answer, things got a little mystical I find.
I found that python code.
import locale print locale.getdefaultlocale() >> ('en_DK', 'UTF-8')
And indeed locale.setlocale(locale.LC_TIME, 'en_DK.UTF-8') works
Using tips here I tested further to see what is available using python code
import locale loc_list = [(a,b) for a,b in locale.locale_alias.items() ] loc_size = len(loc_list) print loc_size,'entries' for loc in loc_list: try: locale.setlocale(locale.LC_TIME, loc[1]) print 'SUCCES set {:12} ({})'.format(loc[1],loc[0]) except: pass
which yields
858 entries SUCCES set en_US.UTF-8 (univ) SUCCES set C (c.ascii) SUCCES set C (c.en) SUCCES set C (posix-utf2) SUCCES set C (c) SUCCES set C (c_c) SUCCES set C (c_c.c) SUCCES set en_IE.UTF-8 (en_ie.utf8@euro) SUCCES set en_US.UTF-8 (universal.utf8@ucs4) SUCCES set C (posix) SUCCES set C (english_united-states.437) SUCCES set en_US.UTF-8 (universal)
Of which only above is working! But the en_DK.UTF-8 is not in this list, though it works!?!? What?? And the python generated locale list do contain a lot of combos of da and DK, which I am looking for, but again no UTF-8 for da/DK...
I am on a Point Linux distro (Debian based), and here locale says amongst other LC_TIME="en_DK.UTF-8", which I know works, but not the locale I need.
locale -a says
C C.UTF-8 en_DK.utf8 en_US.utf8 POSIX
So definitely need to install other locale, which i did by editing /etc/locale.gen, uncomment needed line da_DK.UTF-8 UTF-8 and run command locale-gen
Now locale.setlocale(locale.LC_TIME, 'da_DK.UTF-8') works too, and I can get my localized day and month names.
My Conclision:
Python : locale.locale_alias is not at all helpfull in finding available locales!!!
Linux : It is quite easy to get locale list and install new locale. A lot of help available.
Windows : I have been investigating a little, but nothing conclusive. There are though posts leading to answers, but I have not felt the urge to pursue it.
de_DElisted inlocale -a? If not you must install it.locale.setlocale(locale.LC_ALL, 'de_DE')is wrong. You needlocale.setlocale(locale.LC_ALL, 'de_DE.utf8').locale.setlocale(locale.LC_ALL, locale.locale_aliases['de_DE']).