From c5b68976e118e1d17f7dd607ace6d304ee27d879 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Sat, 4 Jun 2005 04:06:47 +0000 Subject: [PATCH] * src/DateHandler.py: add more English locales * src/dates/Date_fi.py: fix estimated/calculated, handle span properly * src/dates/Makefile.am: remove Date_fi for 2.0.2 svn: r4782 --- gramps2/ChangeLog | 6 ++++++ gramps2/src/DateHandler.py | 29 +++++++++++++++++++++++++---- gramps2/src/DateParser.py | 14 ++++++-------- gramps2/src/dates/Date_de.py | 4 ++-- gramps2/src/dates/Date_es.py | 4 ++-- gramps2/src/dates/Date_fi.py | 6 +++--- gramps2/src/dates/Date_fr.py | 4 ++-- gramps2/src/dates/Date_ru.py | 4 ++-- gramps2/src/dates/Makefile.am | 3 ++- 9 files changed, 50 insertions(+), 24 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index b67bf5a13..e50b8973c 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2005-06-03 Don Allingham + * src/DateHandler.py: add more English locales + * src/dates/Date_fi.py: fix estimated/calculated, handle span + properly + * src/dates/Makefile.am: remove Date_fi for 2.0.2 + 2005-06-04 Eero Tamminen * src/po/fi.po: Updated translation to 2.0.2 template.pot. Everything except for a few dozen tips is translated. diff --git a/gramps2/src/DateHandler.py b/gramps2/src/DateHandler.py index d296c265e..38002d9ab 100644 --- a/gramps2/src/DateHandler.py +++ b/gramps2/src/DateHandler.py @@ -49,21 +49,41 @@ _lang = locale.getlocale(locale.LC_TIME)[0] _lang_to_parser = { 'C' : DateParser.DateParser, - 'en_US' : DateParser.DateParser, - 'en_GB' : DateParser.DateParser, 'en_AU' : DateParser.DateParser, + 'en_BW' : DateParser.DateParser, 'en_CA' : DateParser.DateParser, + 'en_DK' : DateParser.DateParser, + 'en_GB' : DateParser.DateParser, + 'en_HK' : DateParser.DateParser, + 'en_IE' : DateParser.DateParser, + 'en_IN' : DateParser.DateParser, + 'en_NZ' : DateParser.DateParser, + 'en_PH' : DateParser.DateParser, 'en_SE' : DateParser.DateParser, + 'en_SG' : DateParser.DateParser, + 'en_US' : DateParser.DateParser, + 'en_ZA' : DateParser.DateParser, + 'en_ZW' : DateParser.DateParser, 'en' : DateParser.DateParser, } _lang_to_display = { 'C' : DateDisplay.DateDisplayEn, - 'en_US' : DateDisplay.DateDisplayEn, - 'en_GB' : DateDisplay.DateDisplayEn, 'en_AU' : DateDisplay.DateDisplayEn, + 'en_BW' : DateDisplay.DateDisplayEn, 'en_CA' : DateDisplay.DateDisplayEn, + 'en_DK' : DateDisplay.DateDisplayEn, + 'en_GB' : DateDisplay.DateDisplayEn, + 'en_HK' : DateDisplay.DateDisplayEn, + 'en_IE' : DateDisplay.DateDisplayEn, + 'en_IN' : DateDisplay.DateDisplayEn, + 'en_NZ' : DateDisplay.DateDisplayEn, + 'en_PH' : DateDisplay.DateDisplayEn, 'en_SE' : DateDisplay.DateDisplayEn, + 'en_SG' : DateDisplay.DateDisplayEn, + 'en_US' : DateDisplay.DateDisplayEn, + 'en_ZA' : DateDisplay.DateDisplayEn, + 'en_ZW' : DateDisplay.DateDisplayEn, 'en' : DateDisplay.DateDisplayEn, 'zh_CN' : DateDisplay.DateDisplay, 'zh_TW' : DateDisplay.DateDisplay, @@ -142,3 +162,4 @@ try: except: print "Date displayer for",_lang,"not available, using default" displayer = _lang_to_display["C"](val) + diff --git a/gramps2/src/DateParser.py b/gramps2/src/DateParser.py index 891099043..134d150de 100644 --- a/gramps2/src/DateParser.py +++ b/gramps2/src/DateParser.py @@ -257,9 +257,9 @@ class DateParser: re.IGNORECASE) self._qual = re.compile("%s\s+(.+)" % self._qual_str, re.IGNORECASE) - self._span = re.compile("(from)\s+(.+)\s+(to)\s+(.+)", + self._span = re.compile("(from)\s+(?P.+)\s+to\s+(?P.+)", re.IGNORECASE) - self._range = re.compile("(bet|bet.|between)\s+(.+)\s+(and)\s+(.+)", + self._range = re.compile("(bet|bet.|between)\s+(?P.+)\s+and\s+(?P.+)", re.IGNORECASE) self._modifier = re.compile('%s\s+(.*)' % self._mod_str, re.IGNORECASE) @@ -452,10 +452,9 @@ class DateParser: """ match = self._span.match(text) if match: - grps = match.groups() text_parser = self.parser[cal] - start = self._parse_subdate(grps[1],text_parser) - stop = self._parse_subdate(grps[3],text_parser) + start = self._parse_subdate(match.group('start'),text_parser) + stop = self._parse_subdate(match.group('stop'),text_parser) date.set(qual,Date.MOD_SPAN,cal,start + stop) return 1 return 0 @@ -468,10 +467,9 @@ class DateParser: """ match = self._range.match(text) if match: - grps = match.groups() text_parser = self.parser[cal] - start = self._parse_subdate(grps[1],text_parser) - stop = self._parse_subdate(grps[3],text_parser) + start = self._parse_subdate(match.group('start'),text_parser) + stop = self._parse_subdate(match.group('stop'),text_parser) date.set(qual,Date.MOD_RANGE,cal,start + stop) return 1 return 0 diff --git a/gramps2/src/dates/Date_de.py b/gramps2/src/dates/Date_de.py index 04071987f..9f5e1fdc3 100644 --- a/gramps2/src/dates/Date_de.py +++ b/gramps2/src/dates/Date_de.py @@ -112,8 +112,8 @@ class DateParserDE(DateParser): def init_strings(self): DateParser.init_strings(self) - self._span = re.compile("(von|vom)\s+(.+)\s+(bis)\s+(.+)",re.IGNORECASE) - self._range = re.compile("(zwischen)\s+(.+)\s+(und)\s+(.+)", re.IGNORECASE) + self._span = re.compile("(von|vom)\s+(?P.+)\s+(bis)\s+(?P.+)",re.IGNORECASE) + self._range = re.compile("zwischen\s+(?P.+)\s+und\s+(?P.+)", re.IGNORECASE) self._text2 = re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._mon_str, re.IGNORECASE) self._jtext2= re.compile('(\d+)?.?\s+?%s\s*((\d+)(/\d+)?)?' % self._jmon_str, diff --git a/gramps2/src/dates/Date_es.py b/gramps2/src/dates/Date_es.py index 04f36f93f..114a90b22 100644 --- a/gramps2/src/dates/Date_es.py +++ b/gramps2/src/dates/Date_es.py @@ -98,10 +98,10 @@ class DateParserES(DateParser): _span_2 = [u'a'] _range_1 = [u'ent.',u'ent',u'entre'] _range_2 = [u'y'] - self._span = re.compile("(%s)\s+(.+)\s+(%s)\s+(.+)" % + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_span_1),'|'.join(_span_2)), re.IGNORECASE) - self._range = re.compile("(%s)\s+(.+)\s+(%s)\s+(.+)" % + self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_range_1),'|'.join(_range_2)), re.IGNORECASE) diff --git a/gramps2/src/dates/Date_fi.py b/gramps2/src/dates/Date_fi.py index 64fff9709..c20293138 100644 --- a/gramps2/src/dates/Date_fi.py +++ b/gramps2/src/dates/Date_fi.py @@ -95,9 +95,9 @@ class DateParserFI(DateParser): def init_strings(self): DateParser.init_strings(self) # date, whitespace - self._span = re.compile("(.+)\s+-\s+(.+)", + self._span = re.compile("(?P.+)\s+(-)\s+(?P.+)", re.IGNORECASE) - self._range = re.compile("(vuosien\s*)?(.+)\s+ja\s+(.+)\s+väliltä", + self._range = re.compile("(vuosien\s*)?(?P.+)\s+ja\s+(?P.+)\s+väliltä", re.IGNORECASE) #------------------------------------------------------------------------- @@ -114,7 +114,7 @@ class DateDisplayFI(DateDisplay): u"(Persialainen)", u"(Islamilainen)") - _qual_str = ("", "laskettuna", "arviolta") + _qual_str = ("", "arviolta", "laskettuna") formats = ( "VVVV-KK-PP (ISO)", diff --git a/gramps2/src/dates/Date_fr.py b/gramps2/src/dates/Date_fr.py index 5dddc2b44..8b58cf254 100644 --- a/gramps2/src/dates/Date_fr.py +++ b/gramps2/src/dates/Date_fr.py @@ -92,10 +92,10 @@ class DateParserFR(DateParser): _span_2 = [u'à'] _range_1 = [u'ent.',u'ent',u'entre'] _range_2 = [u'et'] - self._span = re.compile("(%s)\s+(.+)\s+(%s)\s+(.+)" % + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_span_1),'|'.join(_span_2)), re.IGNORECASE) - self._range = re.compile("(%s)\s+(.+)\s+(%s)\s+(.+)" % + self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_range_1),'|'.join(_range_2)), re.IGNORECASE) diff --git a/gramps2/src/dates/Date_ru.py b/gramps2/src/dates/Date_ru.py index 5fc453ab5..ffd1abb1f 100644 --- a/gramps2/src/dates/Date_ru.py +++ b/gramps2/src/dates/Date_ru.py @@ -102,10 +102,10 @@ class DateParserRU(DateParser): _span_2 = [u'по',u'до'] _range_1 = [u'между',u'меж',u'меж.'] _range_2 = [u'и'] - self._span = re.compile("(%s)\s+(.+)\s+(%s)\s+(.+)" % + self._span = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_span_1),'|'.join(_span_2)), re.IGNORECASE) - self._range = re.compile("(%s)\s+(.+)\s+(%s)\s+(.+)" % + self._range = re.compile("(%s)\s+(?P.+)\s+(%s)\s+(?P.+)" % ('|'.join(_range_1),'|'.join(_range_2)), re.IGNORECASE) diff --git a/gramps2/src/dates/Makefile.am b/gramps2/src/dates/Makefile.am index ef134d6a3..b081ab11a 100644 --- a/gramps2/src/dates/Makefile.am +++ b/gramps2/src/dates/Makefile.am @@ -9,9 +9,10 @@ pkgdata_PYTHON = \ Date_de.py\ Date_ru.py\ Date_fr.py\ - Date_fi.py\ Date_es.py +# Date_fi.py + pkgpyexecdir = @pkgpyexecdir@/dates pkgpythondir = @pkgpythondir@/dates