gh-130665: Only apply locale to calendar CLI via --locale and not LANG env var (#130676)

This commit is contained in:
Hugo van Kemenade 2025-02-28 16:24:05 +02:00 committed by GitHub
parent e21863ce78
commit c1b4a6bd61
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View File

@ -648,7 +648,7 @@ class LocaleHTMLCalendar(HTMLCalendar):
return super().formatmonthname(theyear, themonth, withyear)
class _CLIDemoCalendar(LocaleTextCalendar):
class _CLIDemoCalendar(TextCalendar):
def __init__(self, highlight_day=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.highlight_day = highlight_day
@ -752,6 +752,12 @@ class _CLIDemoCalendar(LocaleTextCalendar):
return ''.join(v)
class _CLIDemoLocaleCalendar(LocaleTextCalendar, _CLIDemoCalendar):
def __init__(self, highlight_day=None, *args, **kwargs):
super().__init__(*args, **kwargs)
self.highlight_day = highlight_day
# Support for old module level interface
c = TextCalendar()
@ -893,7 +899,7 @@ def main(args=None):
write(cal.formatyearpage(options.year, **optdict))
else:
if options.locale:
cal = _CLIDemoCalendar(highlight_day=today, locale=locale)
cal = _CLIDemoLocaleCalendar(highlight_day=today, locale=locale)
else:
cal = _CLIDemoCalendar(highlight_day=today)
cal.setfirstweekday(options.first_weekday)

View File

@ -0,0 +1,2 @@
Only apply locale to :ref:`calendar CLI <calendar-cli>` when set via
``--locale`` and not via ``LANG`` environment variable.