Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old November 6th, 2006, 11:45 AM
robert
Guest
 
Posts: n/a
Default 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.
Quote:
Quote:
Quote:
>>import locale
>>locale.getlocale()
(None, None)
Quote:
Quote:
Quote:
>>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
Quote:
Quote:
Quote:
>>locale.getdefaultlocale()
('de_DE', 'cp1252')
Quote:
Quote:
Quote:
>>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
Quote:
Quote:
Quote:
>>locale.setlocale(locale.LC_ALL)
'C'
Quote:
Quote:
Quote:
>>locale.setlocale(locale.LC_ALL,'')
'German_Germany.1252'
Quote:
Quote:
Quote:
>>locale.getlocale()
('de_DE', 'cp1252')
Quote:
Quote:
Quote:
>>>
  #2  
Old November 6th, 2006, 01:15 PM
Leo Kislov
Guest
 
Posts: n/a
Default Re: Erronous "unsupported locale setting" ?

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

  #3  
Old November 6th, 2006, 02:05 PM
robert
Guest
 
Posts: n/a
Default Re: Erronous "unsupported locale setting" ?

Leo Kislov wrote:
Quote:
robert wrote:
Quote:
>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
Quote:
Quote:
Quote:
>>locale.getlocale() / getdefaultlocale()
('de_DE', 'cp1252')
already deliver ?

but only this works
Quote:
Quote:
Quote:
>>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
  #4  
Old November 6th, 2006, 08:15 PM
Leo Kislov
Guest
 
Posts: n/a
Default Re: Erronous "unsupported locale setting" ?


robert wrote:
Quote:
Leo Kislov wrote:
Quote:
robert wrote:
Quote:
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
Quote:
Quote:
>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

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles