469,631 Members | 1,301 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

Erronous "unsupported locale setting" ?

Why can the default locale not be set by its true name? but only by '' ? :
PythonWin 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win32.
>>import locale
locale.getlocale()
(None, None)
>>locale.setlocale(locale.LC_ALL,"de_DE")
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\locale.py", line 476, in setlocale
return _setlocale(category, locale)
Error: unsupported locale setting
>>locale.getdefaultlocale()
('de_DE', 'cp1252')
>>locale.setlocale(locale.LC_ALL,locale.getdefault locale())
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\locale.py", line 476, in setlocale
return _setlocale(category, locale)
Error: unsupported locale setting
>>locale.setlocale(locale.LC_ALL)
'C'
>>locale.setlocale(locale.LC_ALL,'')
'German_Germany.1252'
>>locale.getlocale()
('de_DE', 'cp1252')
>>>
Nov 6 '06 #1
3 6947
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')

-- Leo

Nov 6 '06 #2
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 ?

but only this works
>>locale.setlocale(locale.LC_ALL,'German_Germany.1 252')
'German_Germany.1252'
But 'German_Germany.1252' you cannot get/guess from any locale.getxxxx function I think ...
-robert
Nov 6 '06 #3

robert wrote:
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.

-- Leo

Nov 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dayne | last post: by
2 posts views Thread by Ken Schutte | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.