"getdefaultlocale"

Liste des GroupesRevenir à cl python 
Sujet : "getdefaultlocale"
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 01. Oct 2023, 15:04:48
Autres entêtes
Organisation : Stefan Ram
Message-ID : <getdefaultlocale-20231001145557@ram.dialup.fu-berlin.de>
  "getdefaultlocale" is deprecated. "getlocale" is suggested as
  a replacement. But "getlocale" does not seem to return RFC 1766
  language codes as promised in the documentation.

  main.py

import locale

print( locale.getdefaultlocale() )
print( locale.getlocale() )

  output

('en_US', 'cp1252')
('English_United States', '1252')

  From the documentation

|locale.getlocale(category=LC_CTYPE)
|
|Returns the current setting for the given locale category as
|sequence containing language code, encoding. category may be
|one of the LC_* values except LC_ALL. It defaults to LC_CTYPE.
|
|Except for the code 'C', the language code corresponds to
|RFC 1766. language code and encoding may be None if their
|values cannot be determined.

  How can I now convert "English_United States" into "en-US"
  (and for other languages and countries too)?



Date Sujet#  Auteur
1 Oct 23 * "getdefaultlocale"2Stefan Ram
1 Oct 23 `- Re: "getdefaultlocale"1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal