• Re: "getdefaultlocale"

    From Stefan Ram@21:1/5 to Stefan Ram on Sun Oct 1 14:13:25 2023
    ram@zedat.fu-berlin.de (Stefan Ram) writes:
    "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.

    on Windows

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stefan Ram@21:1/5 to All on Sun Oct 1 14:04:48 2023
    "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)?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)