Sorry, something went wrong.
Sorry, something went wrong.
|
Example with cal_locale.py attached to bpo-46659. Run the program in English, but switch to a french locale before creating the LocaleTextCalendar() instance. Current behavior: calendar speaks English, even if the current LC_TIME locale is French: $ LC_ALL=en_US.utf8 ./python cal_locale.py fr_FR.utf8
locale.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.utf8
locale.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. |
Sorry, something went wrong.
|
Would not be more correct to use locale.getlocale(locale.LC_TIME)? |
Sorry, something went wrong.
|
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)? |
Sorry, something went wrong.
|
Would not be more correct to use locale.getlocale(locale.LC_TIME)? You're right: done. |
Sorry, something went wrong.
|
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. |
Sorry, something went wrong.
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