This class can be passed a locale name in the constructor and will return month and weekday names in the specified locale.
| 629 | |
| 630 | |
| 631 | class LocaleHTMLCalendar(HTMLCalendar): |
| 632 | """ |
| 633 | This class can be passed a locale name in the constructor and will return |
| 634 | month and weekday names in the specified locale. |
| 635 | """ |
| 636 | def __init__(self, firstweekday=0, locale=None): |
| 637 | HTMLCalendar.__init__(self, firstweekday) |
| 638 | if locale is None: |
| 639 | locale = _get_default_locale() |
| 640 | self.locale = locale |
| 641 | |
| 642 | def formatweekday(self, day): |
| 643 | with different_locale(self.locale): |
| 644 | return super().formatweekday(day) |
| 645 | |
| 646 | def formatmonthname(self, theyear, themonth, withyear=True): |
| 647 | with different_locale(self.locale): |
| 648 | return super().formatmonthname(theyear, themonth, withyear) |
| 649 | |
| 650 | |
| 651 | class _CLIDemoCalendar(TextCalendar): |