From 96c2db0538cd92b91fc185f783709ef7c2327c93 Mon Sep 17 00:00:00 2001 From: Vassilii Khachaturov Date: Fri, 25 Oct 2013 16:26:58 +0000 Subject: [PATCH] 7158: localize "today" in DateParser Should we also support prefixes? svn: r23408 --- gramps/gen/datehandler/_dateparser.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gramps/gen/datehandler/_dateparser.py b/gramps/gen/datehandler/_dateparser.py index 63df5e401..88be0c382 100644 --- a/gramps/gen/datehandler/_dateparser.py +++ b/gramps/gen/datehandler/_dateparser.py @@ -304,7 +304,12 @@ class DateParser(object): } # (overridden if a locale-specific date parser exists) - today = ["today",] # token(s) to regonise for today's date. + today = ["$T",] + # Override with a list of *synonyms* for "today" in your language. + # Note: the word "today" itself will already be pulled in from your translation DB, + # see init_strings, so there is no need to override this if you have no aliases + # for "today". + # We also secretly support "$T" like in some reports. _langs = set() def __init_prefix_tables(self): @@ -374,6 +379,7 @@ class DateParser(object): can be coded after DateParser.init_strings(self) call, that way they override stuff from this method. See DateParserRU() as an example. """ + _ = self._locale.translation.gettext self.__init_prefix_tables() self._rfc_mon_str = '(' + '|'.join(list(self._rfc_mons_to_int.keys())) + ')' @@ -394,7 +400,7 @@ class DateParser(object): self._cal_str = self.re_longest_first(list(self.calendar_to_int.keys())) self._ny_str = self.re_longest_first(list(self.newyear_to_int.keys())) - self._today_str = self.re_longest_first(self.today) + self._today_str = self.re_longest_first(self.today + [_("today"),]) # bce, calendar type and quality may be either at the end or at # the beginning of the given date string, therefore they will