-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
gh-87281: Improve documentation for locale.setlocale() and locale.getlocale() #137313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
60a26f7
b78ca1b
10228bc
53d7bcb
1a16363
d3aa0bd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…locale()
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -34,12 +34,18 @@ The :mod:`locale` module defines the following exception and functions: | |||||
|
||||||
If *locale* is given and not ``None``, :func:`setlocale` modifies the locale | ||||||
setting for the *category*. The available categories are listed in the data | ||||||
description below. *locale* may be a string, or an iterable of two strings | ||||||
(language code and encoding). If it's an iterable, it's converted to a locale | ||||||
description below. *locale* may be a string, or a pair, | ||||||
language code and encoding. If it is a pair, it is converted to a locale | ||||||
name using the locale aliasing engine. An empty string specifies the user's | ||||||
default settings. If the modification of the locale fails, the exception | ||||||
:exc:`Error` is raised. If successful, the new locale setting is returned. | ||||||
|
||||||
The format of the *locale* and the language code strings is platform | ||||||
depended, but the forms ``language[_territory][.encoding][@modifier]`` | ||||||
and ``language[_territory]`` respectively are typically accepted on all | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I'm not sure what this is referring to? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It refers to the locale and the language code strings. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is not clear, we can only specify format for locale, and then say that the language code has the same format, but without encoding and modifier (support for modifiers will be added in #137253). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd write: "the form The second version you mention is already included in this. |
||||||
platforms. | ||||||
The language code and encoding can be ``None``. | ||||||
|
||||||
If *locale* is omitted or ``None``, the current setting for *category* is | ||||||
returned. | ||||||
|
||||||
|
@@ -345,22 +351,26 @@ The :mod:`locale` module defines the following exception and functions: | |||||
``'LANG'``. The GNU gettext search path contains ``'LC_ALL'``, | ||||||
``'LC_CTYPE'``, ``'LANG'`` and ``'LANGUAGE'``, in that order. | ||||||
|
||||||
Except for the code ``'C'``, the language code corresponds to :rfc:`1766`. | ||||||
*language code* and *encoding* may be ``None`` if their values cannot be | ||||||
The format of the language code is platform depended, but on Posix | ||||||
StanFromIreland marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
platforms it usually looks like ``language[_territory]``. | ||||||
The language code and encoding may be ``None`` if their values cannot be | ||||||
malemburg marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
determined. | ||||||
The "C" locale is represented as ``(None, None)``. | ||||||
|
||||||
.. deprecated-removed:: 3.11 3.15 | ||||||
|
||||||
|
||||||
.. function:: 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 :const:`!LC_\*` values | ||||||
Returns the current setting for the given locale category as a tuple containing | ||||||
language code and encoding. *category* may be one of the :const:`!LC_\*` values | ||||||
except :const:`LC_ALL`. It defaults to :const:`LC_CTYPE`. | ||||||
serhiy-storchaka marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
Except for the code ``'C'``, the language code corresponds to :rfc:`1766`. | ||||||
*language code* and *encoding* may be ``None`` if their values cannot be | ||||||
The format of the language code is platform depended, but on Posix | ||||||
serhiy-storchaka marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
platforms it usually looks like ``language[_territory]``. | ||||||
malemburg marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
The language code and encoding may be ``None`` if their values cannot be | ||||||
determined. | ||||||
The "C" locale is represented as ``(None, None)``. | ||||||
|
||||||
|
||||||
.. function:: getpreferredencoding(do_setlocale=True) | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.