This class can be passed a locale name in the constructor and will return month and weekday names in the specified locale.
| 662 | |
| 663 | |
| 664 | class LocaleHTMLCalendar(HTMLCalendar): |
| 665 | """ |
| 666 | This class can be passed a locale name in the constructor and will return |
| 667 | month and weekday names in the specified locale. |
| 668 | """ |
| 669 | def __init__(self, firstweekday=0, locale=None): |
| 670 | HTMLCalendar.__init__(self, firstweekday) |
| 671 | if locale is None: |
| 672 | locale = _get_default_locale() |
| 673 | self.locale = locale |
| 674 | |
| 675 | def formatweekday(self, day): |
| 676 | with different_locale(self.locale): |
| 677 | return super().formatweekday(day) |
| 678 | |
| 679 | def formatmonthname(self, theyear, themonth, withyear=True): |
| 680 | with different_locale(self.locale): |
| 681 | return super().formatmonthname(theyear, themonth, withyear) |
| 682 | |
| 683 | |
| 684 | class _CLIDemoCalendar(TextCalendar): |
no outgoing calls
no test coverage detected
searching dependent graphs…