Erronous "unsupported locale setting" ?
Leo.Kislov at gmail.com
Mon Nov 6 21:29:08 CET 2006
> Leo Kislov wrote:
> > robert wrote:
> >> Why can the default locale not be set by its true name? but only by '' ? :
> > Probably it is just not implemented. But since locale names are system
> > specific (For example windows accepts 'ch' as Chinese in Taiwan, where
> > as IANA <http://www.iana.org/assignments/language-subtag-registry>
> > considers it Chamorro) setlocale should probably grow an additional
> > keyword parameter: setlocale(LC_ALL, iana='de-DE')
> that'd be another fat database to blow up the python core(s).
> I just wonder why locale.setlocale(locale.LC_ALL,"de_DE") doesn't accept the name, which
> >>> locale.getlocale() / getdefaultlocale()
> ('de_DE', 'cp1252')
> already deliver ?
It is documented that those functions return cross platform RFC 1766
language code. This code sometimes won't be compatible with OS specific
locale name. Cross platform code can useful if you want to create your
own locale database for example cross platform language packs.
Right now we have:
setlocale(category) -- get(it's not a typo) OS locale name
getlocale(category) -- get cross platform locale name
setlocale(category,'') -- enable default locale, return OS locale name
getdefaultlocale() -- get cross platform locale name
I agree it's very confusing API, especially setlocale acting like
getter, but that's what we have. Improvement is welcome.
More information about the Python-list