Erronous "unsupported locale setting" ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • robert

    #1

    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.getloc ale()
    (None, None)
    >>locale.setloc ale(locale.LC_A LL,"de_DE")
    Traceback (most recent call last):
    File "<interacti ve input>", line 1, in <module>
    File "C:\Python25\li b\locale.py", line 476, in setlocale
    return _setlocale(cate gory, locale)
    Error: unsupported locale setting
    >>locale.getdef aultlocale()
    ('de_DE', 'cp1252')
    >>locale.setloc ale(locale.LC_A LL,locale.getde faultlocale())
    Traceback (most recent call last):
    File "<interacti ve input>", line 1, in <module>
    File "C:\Python25\li b\locale.py", line 476, in setlocale
    return _setlocale(cate gory, locale)
    Error: unsupported locale setting
    >>locale.setloc ale(locale.LC_A LL)
    'C'
    >>locale.setloc ale(locale.LC_A LL,'')
    'German_Germany .1252'
    >>locale.getloc ale()
    ('de_DE', 'cp1252')
    >>>
  • Leo Kislov

    #2
    Re: Erronous &quot;unsupport ed locale setting&quot; ?

    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_AL L, iana='de-DE')

    -- Leo

    Comment

    • robert

      #3
      Re: Erronous &quot;unsupport ed locale setting&quot; ?

      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_AL L, iana='de-DE')
      that'd be another fat database to blow up the python core(s).

      I just wonder why locale.setlocal e(locale.LC_ALL ,"de_DE") doesn't accept the name, which
      >>locale.getloc ale() / getdefaultlocal e()
      ('de_DE', 'cp1252')
      already deliver ?

      but only this works
      >>locale.setloc ale(locale.LC_A LL,'German_Germ any.1252')
      'German_Germany .1252'


      But 'German_Germany .1252' you cannot get/guess from any locale.getxxxx function I think ...


      -robert

      Comment

      • Leo Kislov

        #4
        Re: Erronous &quot;unsupport ed locale setting&quot; ?


        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_AL L, iana='de-DE')
        >
        that'd be another fat database to blow up the python core(s).
        >
        I just wonder why locale.setlocal e(locale.LC_ALL ,"de_DE") doesn't accept the name, which
        >locale.getloca le() / getdefaultlocal e()
        ('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(categ ory) -- get(it's not a typo) OS locale name
        getlocale(categ ory) -- get cross platform locale name
        setlocale(categ ory,'') -- enable default locale, return OS locale name
        getdefaultlocal e() -- 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

        Comment

        Working...