diff --git a/gramps/gen/datehandler/__init__.py b/gramps/gen/datehandler/__init__.py index 51101fdd8..7efbc7fab 100644 --- a/gramps/gen/datehandler/__init__.py +++ b/gramps/gen/datehandler/__init__.py @@ -94,7 +94,7 @@ except: # Import utility functions from ._dateutils import * -from ._grampslocale import (codeset, long_days, short_days, tformat) +from ._grampslocale import (codeset, tformat) if __name__ == "__main__": from ._datedisplay import DateDisplay diff --git a/gramps/gen/datehandler/_datedisplay.py b/gramps/gen/datehandler/_datedisplay.py index 89ee22f2c..a3d84039a 100644 --- a/gramps/gen/datehandler/_datedisplay.py +++ b/gramps/gen/datehandler/_datedisplay.py @@ -120,6 +120,7 @@ class DateDisplay(object): self._display_swedish] self._mod_str = self._ds.modifiers self._qual_str = self._ds.qualifiers + self.long_days = self._ds.long_days if format is None: self.format = 0 diff --git a/gramps/gen/datehandler/_datestrings.py b/gramps/gen/datehandler/_datestrings.py index 656e01c7e..2bf4324fd 100644 --- a/gramps/gen/datehandler/_datestrings.py +++ b/gramps/gen/datehandler/_datestrings.py @@ -217,9 +217,17 @@ class DateStrings(object): _("date quality|calculated "), ) - - # TODO extend with further strings - # along with the date displayer and parser refactoring + # 6753: localized day names. Eventually should sprout into + # a per-calendar type thing instead. + self.long_days = ("", + _("Sunday"), + _("Monday"), + _("Tuesday"), + _("Wednesday"), + _("Thursday"), + _("Friday"), + _("Saturday"), + ) __doc__ += """ __main__ @@ -242,7 +250,8 @@ if __name__ == '__main__': from ..utils.grampslocale import GrampsLocale from gramps.gen.const import GRAMPS_LOCALE as glocale from ._grampslocale import (_deprecated_long_months as old_long, - _deprecated_short_months as old_short) + _deprecated_short_months as old_short, + _deprecated_long_days as old_days) from ._datedisplay import DateDisplay import gettext lang = glocale.lang @@ -344,3 +353,5 @@ if __name__ == '__main__': "date quality|") except AttributeError: pass + + print_po_snippet((ds_EN.long_days, old_days, old_days), "") diff --git a/gramps/gen/datehandler/_grampslocale.py b/gramps/gen/datehandler/_grampslocale.py index 617daf066..010535908 100644 --- a/gramps/gen/datehandler/_grampslocale.py +++ b/gramps/gen/datehandler/_grampslocale.py @@ -85,7 +85,7 @@ try: # not the international convention (ISO 8601) that Monday # is the first day of the week." # see http://docs.python.org/library/locale.html - long_days = ( + _deprecated_long_days = ( "", to_uni(locale.nl_langinfo(locale.DAY_1), codeset), # Sunday to_uni(locale.nl_langinfo(locale.DAY_2), codeset), # Monday @@ -96,7 +96,7 @@ try: to_uni(locale.nl_langinfo(locale.DAY_7), codeset), # Saturday ) - short_days = ( + _deprecated_short_days = ( "", to_uni(locale.nl_langinfo(locale.ABDAY_1), codeset), # Sunday to_uni(locale.nl_langinfo(locale.ABDAY_2), codeset), # Monday @@ -156,7 +156,7 @@ except: # number. tm_wday => range [0,6], Monday is 0 # Note. Only the seventh tuple entry matters. The others are # just a dummy. - long_days = ( + _deprecated_long_days = ( "", to_uni(time.strftime('%A',(1,1,1,1,1,1,6,1,1)), codeset), # Sunday to_uni(time.strftime('%A',(1,1,1,1,1,1,0,1,1)), codeset), # Monday @@ -167,7 +167,7 @@ except: to_uni(time.strftime('%A',(1,1,1,1,1,1,5,1,1)), codeset), # Saturday ) - short_days = ( + _deprecated_short_days = ( "", to_uni(time.strftime('%a',(1,1,1,1,1,1,6,1,1)), codeset), # Sunday to_uni(time.strftime('%a',(1,1,1,1,1,1,0,1,1)), codeset), # Monday diff --git a/gramps/gen/datehandler/test/datestrings_test.py b/gramps/gen/datehandler/test/datestrings_test.py index 6157b26af..8b722c1cb 100644 --- a/gramps/gen/datehandler/test/datestrings_test.py +++ b/gramps/gen/datehandler/test/datestrings_test.py @@ -66,6 +66,7 @@ class DateStringsTest(unittest.TestCase): self.assertEqual(self.ds.long_months[0], "") self.assertEqual(self.ds.short_months[0], "") self.assertEqual(self.ds.alt_long_months[0], "") + self.assertEqual(self.ds.long_days[0], "") def testCalendarIndex(self): self.assertEqual(self.ds_EN.calendar[Date.CAL_GREGORIAN], "Gregorian") @@ -76,5 +77,8 @@ class DateStringsTest(unittest.TestCase): self.assertEqual(self.ds_EN.calendar[Date.CAL_ISLAMIC], "Islamic") self.assertEqual(self.ds_EN.calendar[Date.CAL_SWEDISH], "Swedish") + def testDayNamesLenIs8(self): + self.assertEqual(len(self.ds.long_days), 8) + if __name__ == "__main__": unittest.main() diff --git a/gramps/gen/plug/report/_reportbase.py b/gramps/gen/plug/report/_reportbase.py index 478809209..227e740d3 100644 --- a/gramps/gen/plug/report/_reportbase.py +++ b/gramps/gen/plug/report/_reportbase.py @@ -67,6 +67,7 @@ class Report(object): self._ = locale.translation.gettext self._get_date = locale.get_date self._get_type = locale.get_type + self._dd = locale.date_displayer return locale def write_report(self): diff --git a/gramps/plugins/drawreport/calendarreport.py b/gramps/plugins/drawreport/calendarreport.py index 70b6ba203..43680a4ee 100644 --- a/gramps/plugins/drawreport/calendarreport.py +++ b/gramps/plugins/drawreport/calendarreport.py @@ -52,7 +52,7 @@ from gramps.gen.plug.report import utils as ReportUtils from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import stdoptions from gramps.gen.utils.alive import probably_alive -from gramps.gen.datehandler import displayer as _dd, long_days +from gramps.gen.datehandler import displayer as _dd from gramps.gen.lib import Date, EventRoleType, EventType, Name, NameType, Person, Surname from gramps.gen.lib.date import gregorian @@ -182,6 +182,7 @@ class Calendar(Report): pdaynames = style_sheet.get_paragraph_style("CAL-Daynames") pnumbers = style_sheet.get_paragraph_style("CAL-Numbers") ptext1style = style_sheet.get_paragraph_style("CAL-Text1style") + long_days = _dd.long_days self.doc.start_page() width = self.doc.get_usable_width() @@ -459,6 +460,7 @@ class CalendarOptions(MenuReportOptions): add_option("country", country) start_dow = EnumeratedListOption(_("First day of week"), 1) + long_days = _dd.long_days for count in range(1, 8): # conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize()) diff --git a/gramps/plugins/textreport/birthdayreport.py b/gramps/plugins/textreport/birthdayreport.py index 32451a573..6c8253dd0 100644 --- a/gramps/plugins/textreport/birthdayreport.py +++ b/gramps/plugins/textreport/birthdayreport.py @@ -56,10 +56,12 @@ from gramps.gen.plug.report import utils as ReportUtils from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import stdoptions from gramps.gen.utils.alive import probably_alive -from gramps.gen.datehandler import long_days import gramps.plugins.lib.libholiday as libholiday +# localization for BirthdayOptions only!! +from gramps.gen.datehandler import displayer as _dd + def _T_(value): # enable deferred translations (see Python docs 22.1.3.4) return value # _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh @@ -445,6 +447,7 @@ class BirthdayOptions(MenuReportOptions): menu.add_option(category_name, "country", country) start_dow = EnumeratedListOption(_("First day of week"), 1) + long_days = _dd.long_days for count in range(1, 8): # conversion between gramps numbering (sun=1) and iso numbering (mon=1) of weekdays below start_dow.add_item((count+5) % 7 + 1, long_days[count].capitalize()) diff --git a/gramps/plugins/webreport/webcal.py b/gramps/plugins/webreport/webcal.py index 9ec4dbf91..a77ae6410 100644 --- a/gramps/plugins/webreport/webcal.py +++ b/gramps/plugins/webreport/webcal.py @@ -62,7 +62,7 @@ from gramps.gen.plug.menu import BooleanOption, NumberOption, StringOption, \ DestinationOption, NoteOption from gramps.gen.utils.config import get_researcher from gramps.gen.utils.alive import probably_alive -from gramps.gen.datehandler import displayer as _dd, long_days +from gramps.gen.datehandler import displayer as _dd from gramps.gen.display.name import displayer as _nd @@ -627,7 +627,7 @@ class WebCalReport(Report): # Note. gen.datehandler has sunday => 1, monday => 2, etc # We slice out the first empty element. - day_names = long_days + day_names = _dd.long_days # use self._dd.long_days when set_locale is used... def __get_previous_month_day(year, month, day_col): @@ -1085,7 +1085,7 @@ class WebCalReport(Report): with self._user.progress(_("Web Calendar Report"), _('Applying Filter...'), db.get_number_of_people()) as step: - people = self.filter.apply(db, people, step_progress) + people = self.filter.apply(db, people, step) with self._user.progress(_("Web Calendar Report"), _("Reading database..."), len(people)) as step: @@ -1437,7 +1437,7 @@ class WebCalOptions(MenuReportOptions): # Default selection ???? start_dow = EnumeratedListOption(_("First day of week"), 1) for count in range(1, 8): - start_dow.add_item(count, long_days[count].capitalize()) + start_dow.add_item(count, _dd.long_days[count].capitalize()) start_dow.set_help(_("Select the first day of the week for the calendar")) menu.add_option(category_name, "start_dow", start_dow)