472,358 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,358 software developers and data experts.

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 7078
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: aa | last post by:
Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini in php.ini I have: SMTP = localhost SMTP_PORT = 25...
2
by: Dayne | last post by:
I know I can get the user's last input info with the win32 function "GetLastInputInfo", but how do I set this value without any physical input from the user? Any idea? DT
2
by: AA Arens | last post by:
When I place a record serch utility (vos the button placement wizzrd), I discovered that the Match setting is "Whole Field" by default. How to make "Any Part Of Field" default?
0
by: Torsten Sturm | last post by:
Hello, SP1 of Windows Server introduced a new "feature" in the GlobalizationConfig class called EnableBestFitResponseEncoding. Effect is that when you set anything other than UTF8 in...
2
by: gabon | last post by:
I'm creating a select entirely through JavaScript and very strangely IE doesn't show the text in the option elements. Here part of the code: this.form_country=document.createElement("select");...
2
by: Ken Schutte | last post by:
Lets say I want an integer class that lets you attach arbitrary attributes. I can simply do: class foo(int): pass x = foo(5) x.text = "okay" print x, x.text # prints "5 okay" So,...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
1
by: Kerem Gümrükcü | last post by:
Hi All, i am too tired now to find this out by my own, but why does my while loop "while(readline==Console.ReadLine())" needs twice return hit to read the line, after setting...
0
by: Kirk Wolf | last post by:
The IT folks did an automatic upgrade of DB2 connect to V9 our our Windows machines, and now when we try to use DB2 on z/OS from an Eclipse plugin called "SqlExplorer", we get the following JDBC...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.