FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-87281: Improve documentation for locale.setlocale() and locale.getlocale() by serhiy-storchaka · Pull Request #137313 · python/cpython · GitHub

Repository navigation

gh-87281: Improve documentation for locale.setlocale() and locale.getlocale() - #137313

Merged
serhiy-storchaka merged 6 commits into
python:mainfrom
serhiy-storchaka:locale-docs
Aug 13, 2025
Merged

serhiy-storchaka merged 6 commits into
python:mainfrom
serhiy-storchaka:locale-docs

Conversation

serhiy-storchaka commented Aug 1, 2025 •
edited by github-actions Bot
Loading

Copy link
Copy Markdown
Member

Copy link
Copy Markdown
Member Author

Reference to RFC 1766 was incorrect -- RFC 1766 specifies language and territory separated by a minus instead of underscore, and it does not contain much useful information anyway. Also, getlocale() returns the language code in other format on Windows and some other platforms.

getlocale() does not return code "C", it returns (None, None) for the "C" locale.

Added specification of universally accepted formats. Late @modifier will be added for the language code. This will be made less vague when we guarantee these formats.

Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
and ``language[_territory]`` respectively are typically accepted on all
and ``language[_territory]`` are typically accepted on all

I'm not sure what this is referring to?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It refers to the locale and the language code strings.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'd write: "the form language[_territory][.encoding][@modifier] is typically accepted".

The second version you mention is already included in this.

Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>

serhiy-storchaka left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you for your grammar fixes @StanFromIreland.

Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It refers to the locale and the language code strings.

malemburg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM modulo the small change requests.

Comment thread Doc/library/locale.rst Outdated

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'd write: "the form language[_territory][.encoding][@modifier] is typically accepted".

The second version you mention is already included in this.

Comment thread Doc/library/locale.rst
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Comment thread Doc/library/locale.rst Outdated
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Comment thread Doc/library/locale.rst Outdated
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>

StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

Copy link
Copy Markdown
Member Author

I am going to merge this PR tomorrow if there are no new comments.

serhiy-storchaka merged commit 15ab457 into python:main Aug 13, 2025
github-project-automation Bot moved this from Todo to Done in Docs PRs Aug 13, 2025

Copy link
Copy Markdown

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

serhiy-storchaka deleted the locale-docs branch August 13, 2025 17:49
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 13, 2025
…le.getlocale() (pythonGH-137313)

Add a section explaining the locale name formats.
(cherry picked from commit 15ab457)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 13, 2025
…le.getlocale() (pythonGH-137313)

Add a section explaining the locale name formats.
(cherry picked from commit 15ab457)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>

bedevere-app Bot commented Aug 13, 2025

Copy link
Copy Markdown

GH-137722 is a backport of this pull request to the 3.14 branch.

bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Aug 13, 2025

bedevere-app Bot commented Aug 13, 2025

Copy link
Copy Markdown

GH-137723 is a backport of this pull request to the 3.13 branch.

bedevere-app Bot removed the needs backport to 3.13 only security fixes label Aug 13, 2025
serhiy-storchaka added a commit that referenced this pull request Aug 13, 2025
…ale.getlocale() (GH-137313) (GH-137723)

Add a section explaining the locale name formats.
(cherry picked from commit 15ab457)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
…le.getlocale() (pythonGH-137313)

Add a section explaining the locale name formats.
hugovk pushed a commit that referenced this pull request Sep 11, 2025
…ale.getlocale() (GH-137313) (#137722)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip news

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL