Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

bpo-46659: calendar uses locale.getlocale()#31166

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 2 commits intopython:mainfromvstinner:calendar_defaultlocale
Feb 7, 2022
Merged

bpo-46659: calendar uses locale.getlocale()#31166

vstinner merged 2 commits intopython:mainfromvstinner:calendar_defaultlocale
Feb 7, 2022

Conversation

vstinner
Copy link
Member

@vstinnervstinner commentedFeb 6, 2022
edited by bedevere-bot
Loading

The calendar.LocaleTextCalendar and calendar.LocaleHTMLCalendar
classes module now use locale.getlocale(), instead of using
locale.getdefaultlocale(), if no locale is specified.

https://bugs.python.org/issue46659

The calendar.LocaleTextCalendar and calendar.LocaleHTMLCalendarclasses module now use locale.getlocale(), instead of usinglocale.getdefaultlocale(), if no locale is specified.
@vstinner
Copy link
MemberAuthor

@vstinner
Copy link
MemberAuthor

vstinner commentedFeb 6, 2022
edited
Loading

Example with cal_locale.py attached tobpo-46659. Run the program in English, but switch to a french locale before creating the LocaleTextCalendar() instance.

Current behavior: calendar speaks English, even if thecurrent LC_TIME locale is French:

$ LC_ALL=en_US.utf8 ./python cal_locale.py fr_FR.utf8locale.getlocale()=('fr_FR', 'UTF-8')locale.getdefaultlocale()=('en_US', 'UTF-8')cal.locale=('en_US', 'UTF-8')                                August 2022  Monday    Tuesday   Wednesday   Thursday    Friday    Saturday    Sunday     1          2          3          4          5          6          7     8          9         10         11         12         13         14    15         16         17         18         19         20         21    22         23         24         25         26         27         28    29         30         31

With this PR: calendar speaks French:

$ LC_ALL=en_US.utf8 ./python cal_locale.py fr_FR.utf8locale.getlocale()=('fr_FR', 'UTF-8')locale.getdefaultlocale()=('en_US', 'UTF-8')cal.locale=('fr_FR', 'UTF-8')                                 août 2022  lundi      mardi     mercredi    jeudi     vendredi    samedi    dimanche     1          2          3          4          5          6          7     8          9         10         11         12         13         14    15         16         17         18         19         20         21    22         23         24         25         26         27         28    29         30         31

Applications which don't call setlocale() to change the LC_ALL or LC_TIME locale are not affected.

@serhiy-storchaka
Copy link
Member

Would not be more correct to uselocale.getlocale(locale.LC_TIME)?

@vstinner
Copy link
MemberAuthor

With this PR, the two classes store the current locale when an instance is created. Is it really an important feature?

Or would it be acceptable to use the current locale (don't change the locale) if locale=None is passed (default behavior)?

@vstinner
Copy link
MemberAuthor

Would not be more correct to use locale.getlocale(locale.LC_TIME)?

You're right: done.

@vstinnervstinner merged commit7a0486e intopython:mainFeb 7, 2022
@vstinnervstinner deleted the calendar_defaultlocale branchFebruary 7, 2022 23:24
@vstinner
Copy link
MemberAuthor

Merged, thanks for your reviews.

With this PR, the two classes store the current locale when an instance is created. Is it really an important feature?

In case of doubt, I prefer to leave the code as it is.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@methanemethanemethane approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@vstinner@serhiy-storchaka@methane@the-knights-who-say-ni@bedevere-bot

[8]ページ先頭

©2009-2025 Movatter.jp