From 092a9025dc30010018eba4c75cc7c77eb8581b83 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Sat, 21 Mar 2015 12:49:26 -0700 Subject: [PATCH] fix date displayer TODO: estimated and calculated month inflections --- gramps/gen/datehandler/_datedisplay.py | 162 +++++++++++++++------- po/gramps.pot | 184 +++++++++++++++++-------- 2 files changed, 240 insertions(+), 106 deletions(-) diff --git a/gramps/gen/datehandler/_datedisplay.py b/gramps/gen/datehandler/_datedisplay.py index 4028be35a..d2f59ab2e 100644 --- a/gramps/gen/datehandler/_datedisplay.py +++ b/gramps/gen/datehandler/_datedisplay.py @@ -161,47 +161,70 @@ class DateDisplay(object): "from" # first date in a span - # You only need to translate this string if you translate one of the - # inflect=_("...") with "from" + # If "from " needs a special inflection in your + # language, translate this to "{long_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("from|{long_month} {year}"), "to" # second date in a span - # You only need to translate this string if you translate one of the - # inflect=_("...") with "to" + # If "to " needs a special inflection in your + # language, translate this to "{long_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("to|{long_month} {year}"), "between" # first date in a range - # You only need to translate this string if you translate one of the - # inflect=_("...") with "between" + # If "between " needs a special inflection in your + # language, translate this to "{long_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("between|{long_month} {year}"), "and" # second date in a range - # You only need to translate this string if you translate one of the - # inflect=_("...") with "and" + # If "and " needs a special inflection in your + # language, translate this to "{long_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("and|{long_month} {year}"), "before" # If "before " needs a special inflection in your # language, translate this to "{long_month.f[X]} {year}" # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("before|{long_month} {year}"), "after" # If "after " needs a special inflection in your # language, translate this to "{long_month.f[X]} {year}" # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("after|{long_month} {year}"), "about" # If "about " needs a special inflection in your # language, translate this to "{long_month.f[X]} {year}" # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("about|{long_month} {year}"), - # TODO if no modifier, but with qual, might need to inflect in some lang. + "estimated" + # If "estimated " needs a special inflection in your + # language, translate this to "{long_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated + : _("estimated|{long_month} {year}"), + + "calculated" + # If "calculated " needs a special inflection in your + # language, translate this to "{long_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated + : _("calculated|{long_month} {year}"), } self.FORMATS_short_month_year = { @@ -210,37 +233,70 @@ class DateDisplay(object): "from" # first date in a span + # If "from " needs a special inflection in your + # language, translate this to "{short_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("from|{short_month} {year}"), "to" # second date in a span + # If "to " needs a special inflection in your + # language, translate this to "{short_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("to|{short_month} {year}"), "between" # first date in a range + # If "between " needs a special inflection in your + # language, translate this to "{short_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("between|{short_month} {year}"), "and" # second date in a range + # If "and " needs a special inflection in your + # language, translate this to "{short_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("and|{short_month} {year}"), "before" # If "before " needs a special inflection in your # language, translate this to "{short_month.f[X]} {year}" # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("before|{short_month} {year}"), "after" # If "after " needs a special inflection in your # language, translate this to "{short_month.f[X]} {year}" # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("after|{short_month} {year}"), "about" # If "about " needs a special inflection in your # language, translate this to "{short_month.f[X]} {year}" # (where X is one of the month-name inflections you defined) + # else leave it untranslated : _("about|{short_month} {year}"), + + "estimated" + # If "estimated " needs a special inflection in your + # language, translate this to "{short_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated + : _("estimated|{short_month} {year}"), + + "calculated" + # If "calculated " needs a special inflection in your + # language, translate this to "{short_month.f[X]} {year}" + # (where X is one of the month-name inflections you defined) + # else leave it untranslated + : _("calculated|{short_month} {year}"), } def set_format(self, format): @@ -346,48 +402,40 @@ class DateDisplay(object): return "" elif mod == Date.MOD_SPAN: d1 = self.display_cal[cal](start, - # If there is no special inflection for "from " in your - # language, don't translate this string. - # Otherwise, translate it to the ENGLISH!!! ENGLISH!!! - # key appearing above in the FORMATS_... dict - # that maps to the special inflected format string that you need to localize. - inflect=_("from-date|")) + # If there is no special inflection for "from " + # in your language, DON'T translate this string. Otherwise, + # "translate" this to "from" in ENGLISH!!! ENGLISH!!! + inflect=_("from-date|")) d2 = self.display_cal[cal](date.get_stop_date(), - # If there is no special inflection for "to " in your - # language, don't translate this string. - # Otherwise, translate it to the ENGLISH!!! ENGLISH!!! - # key appearing above in the FORMATS_... dict - # that maps to the special inflected format string that you need to localize. - inflect=_("to-date|")) + # If there is no special inflection for "to " + # in your language, DON'T translate this string. Otherwise, + # "translate" this to "to" in ENGLISH!!! ENGLISH!!! + inflect=_("to-date|")) scal = self.format_extras(cal, newyear) return _("{date_quality}from {date_start} to {date_stop}" - "{nonstd_calendar_and_ny}").format( - date_quality=qual_str, - date_start=d1, - date_stop=d2, - nonstd_calendar_and_ny=scal) + "{nonstd_calendar_and_ny}").format( + date_quality=qual_str, + date_start=d1, + date_stop=d2, + nonstd_calendar_and_ny=scal) elif mod == Date.MOD_RANGE: d1 = self.display_cal[cal](start, - # If there is no special inflection for "between " in your - # language, don't translate this string. - # Otherwise, translate it to the ENGLISH!!! ENGLISH!!! - # key appearing above in the FORMATS_... dict - # that maps to the special inflected format string that you need to localize. - inflect=_("between-date|")) + # If there is no special inflection for "between " + # in your language, DON'T translate this string. Otherwise, + # "translate" this to "between" in ENGLISH!!! ENGLISH!!! + inflect=_("between-date|")) d2 = self.display_cal[cal](date.get_stop_date(), - # If there is no special inflection for "and " in your - # language, don't translate this string. - # Otherwise, translate it to the ENGLISH!!! ENGLISH!!! - # key appearing above in the FORMATS_... dict - # that maps to the special inflected format string that you need to localize. - inflect=_("and-date|")) + # If there is no special inflection for "and " + # in your language, DON'T translate this string. Otherwise, + # "translate" this to "and" in ENGLISH!!! ENGLISH!!! + inflect=_("and-date|")) scal = self.format_extras(cal, newyear) return _("{date_quality}between {date_start} and {date_stop}" - "{nonstd_calendar_and_ny}").format( - date_quality=qual_str, - date_start=d1, - date_stop=d2, - nonstd_calendar_and_ny=scal) + "{nonstd_calendar_and_ny}").format( + date_quality=qual_str, + date_start=d1, + date_stop=d2, + nonstd_calendar_and_ny=scal) else: if mod == Date.MOD_BEFORE: # If there is no special inflection for "before " @@ -404,8 +452,26 @@ class DateDisplay(object): # in your language, DON'T translate this string. Otherwise, # "translate" this to "about" in ENGLISH!!! ENGLISH!!! date_type = _("about-date|") + elif qual == Date.QUAL_ESTIMATED: + # If there is no special inflection for "estimated " + # in your language, DON'T translate this string. Otherwise, + # "translate" this to "estimated" in ENGLISH!!! ENGLISH!!! + date_type = _("estimated-date|") + elif qual == Date.QUAL_CALCULATED: + # If there is no special inflection for "calculated " + # in your language, DON'T translate this string. Otherwise, + # "translate" this to "calculated" in ENGLISH!!! ENGLISH!!! + date_type = _("calculated-date|") else: date_type = "" + # TODO -- do "estimated" and "calculated" need their own "if"? + # i.e., what happens if a date is both "modified" and "qualified"? + # it won't matter if the month gets the same lexeme type, but + # what should be done if the types differ? there can only be one + # lexeme type for any month so which one should be last? so we + # will wait and see if any language ever requires such fine tuning + # as maybe it will be as simple as putting the "elif" choices for + # "estimated" and "calculated" before the others, or something text = self.display_cal[cal](start, inflect=date_type) modifier = self._mod_str[mod] # some languages have a modifier after the date (e.g. Finnish) @@ -415,11 +481,11 @@ class DateDisplay(object): modifier = '' scal = self.format_extras(cal, newyear) return _("{date_quality}{noncompound_modifier}{date}" - "{nonstd_calendar_and_ny}").format( - date_quality=qual_str, - noncompound_modifier=modifier, - date=text, - nonstd_calendar_and_ny=scal) + "{nonstd_calendar_and_ny}").format( + date_quality=qual_str, + noncompound_modifier=modifier, + date=text, + nonstd_calendar_and_ny=scal) def _display_gregorian(self, date_val, **kwargs): return self._display_calendar(date_val, self.long_months, diff --git a/po/gramps.pot b/po/gramps.pot index 036e62d97..0dbb67326 100644 --- a/po/gramps.pot +++ b/po/gramps.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-03-19 19:45-0700\n" +"POT-Creation-Date: 2015-03-21 12:33-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1407,140 +1407,194 @@ msgid "{long_month} {year}" msgstr "" #. first date in a span -#. You only need to translate this string if you translate one of the -#. inflect=_("...") with "from" -#: ../gramps/gen/datehandler/_datedisplay.py:166 +#. If "from " needs a special inflection in your +#. language, translate this to "{long_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:168 msgid "from|{long_month} {year}" msgstr "" #. second date in a span -#. You only need to translate this string if you translate one of the -#. inflect=_("...") with "to" -#: ../gramps/gen/datehandler/_datedisplay.py:172 +#. If "to " needs a special inflection in your +#. language, translate this to "{long_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:176 msgid "to|{long_month} {year}" msgstr "" #. first date in a range -#. You only need to translate this string if you translate one of the -#. inflect=_("...") with "between" -#: ../gramps/gen/datehandler/_datedisplay.py:178 +#. If "between " needs a special inflection in your +#. language, translate this to "{long_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:184 msgid "between|{long_month} {year}" msgstr "" #. second date in a range -#. You only need to translate this string if you translate one of the -#. inflect=_("...") with "and" -#: ../gramps/gen/datehandler/_datedisplay.py:184 +#. If "and " needs a special inflection in your +#. language, translate this to "{long_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:192 msgid "and|{long_month} {year}" msgstr "" #. If "before " needs a special inflection in your #. language, translate this to "{long_month.f[X]} {year}" #. (where X is one of the month-name inflections you defined) -#: ../gramps/gen/datehandler/_datedisplay.py:190 +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:199 msgid "before|{long_month} {year}" msgstr "" #. If "after " needs a special inflection in your #. language, translate this to "{long_month.f[X]} {year}" #. (where X is one of the month-name inflections you defined) -#: ../gramps/gen/datehandler/_datedisplay.py:196 +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:206 msgid "after|{long_month} {year}" msgstr "" #. If "about " needs a special inflection in your #. language, translate this to "{long_month.f[X]} {year}" #. (where X is one of the month-name inflections you defined) -#: ../gramps/gen/datehandler/_datedisplay.py:202 +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:213 msgid "about|{long_month} {year}" msgstr "" -#: ../gramps/gen/datehandler/_datedisplay.py:209 +#. If "estimated " needs a special inflection in your +#. language, translate this to "{long_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:220 +msgid "estimated|{long_month} {year}" +msgstr "" + +#. If "calculated " needs a special inflection in your +#. language, translate this to "{long_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:227 +msgid "calculated|{long_month} {year}" +msgstr "" + +#: ../gramps/gen/datehandler/_datedisplay.py:232 msgid "{short_month} {year}" msgstr "" #. first date in a span -#: ../gramps/gen/datehandler/_datedisplay.py:213 +#. If "from " needs a special inflection in your +#. language, translate this to "{short_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:240 msgid "from|{short_month} {year}" msgstr "" #. second date in a span -#: ../gramps/gen/datehandler/_datedisplay.py:217 +#. If "to " needs a special inflection in your +#. language, translate this to "{short_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:248 msgid "to|{short_month} {year}" msgstr "" #. first date in a range -#: ../gramps/gen/datehandler/_datedisplay.py:221 +#. If "between " needs a special inflection in your +#. language, translate this to "{short_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:256 msgid "between|{short_month} {year}" msgstr "" #. second date in a range -#: ../gramps/gen/datehandler/_datedisplay.py:225 +#. If "and " needs a special inflection in your +#. language, translate this to "{short_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:264 msgid "and|{short_month} {year}" msgstr "" #. If "before " needs a special inflection in your #. language, translate this to "{short_month.f[X]} {year}" #. (where X is one of the month-name inflections you defined) -#: ../gramps/gen/datehandler/_datedisplay.py:231 +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:271 msgid "before|{short_month} {year}" msgstr "" #. If "after " needs a special inflection in your #. language, translate this to "{short_month.f[X]} {year}" #. (where X is one of the month-name inflections you defined) -#: ../gramps/gen/datehandler/_datedisplay.py:237 +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:278 msgid "after|{short_month} {year}" msgstr "" #. If "about " needs a special inflection in your #. language, translate this to "{short_month.f[X]} {year}" #. (where X is one of the month-name inflections you defined) -#: ../gramps/gen/datehandler/_datedisplay.py:243 +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:285 msgid "about|{short_month} {year}" msgstr "" -#. If there is no special inflection for "from " in your -#. language, don't translate this string. -#. Otherwise, translate it to the ENGLISH!!! ENGLISH!!! -#. key appearing above in the FORMATS_... dict -#. that maps to the special inflected format string that you need to localize. -#: ../gramps/gen/datehandler/_datedisplay.py:354 +#. If "estimated " needs a special inflection in your +#. language, translate this to "{short_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:292 +msgid "estimated|{short_month} {year}" +msgstr "" + +#. If "calculated " needs a special inflection in your +#. language, translate this to "{short_month.f[X]} {year}" +#. (where X is one of the month-name inflections you defined) +#. else leave it untranslated +#: ../gramps/gen/datehandler/_datedisplay.py:299 +msgid "calculated|{short_month} {year}" +msgstr "" + +#. If there is no special inflection for "from " +#. in your language, DON'T translate this string. Otherwise, +#. "translate" this to "from" in ENGLISH!!! ENGLISH!!! +#: ../gramps/gen/datehandler/_datedisplay.py:408 msgid "from-date|" msgstr "" -#. If there is no special inflection for "to " in your -#. language, don't translate this string. -#. Otherwise, translate it to the ENGLISH!!! ENGLISH!!! -#. key appearing above in the FORMATS_... dict -#. that maps to the special inflected format string that you need to localize. -#: ../gramps/gen/datehandler/_datedisplay.py:361 +#. If there is no special inflection for "to " +#. in your language, DON'T translate this string. Otherwise, +#. "translate" this to "to" in ENGLISH!!! ENGLISH!!! +#: ../gramps/gen/datehandler/_datedisplay.py:413 msgid "to-date|" msgstr "" -#: ../gramps/gen/datehandler/_datedisplay.py:363 +#: ../gramps/gen/datehandler/_datedisplay.py:415 msgid "{date_quality}from {date_start} to {date_stop}{nonstd_calendar_and_ny}" msgstr "" -#. If there is no special inflection for "between " in your -#. language, don't translate this string. -#. Otherwise, translate it to the ENGLISH!!! ENGLISH!!! -#. key appearing above in the FORMATS_... dict -#. that maps to the special inflected format string that you need to localize. -#: ../gramps/gen/datehandler/_datedisplay.py:376 +#. If there is no special inflection for "between " +#. in your language, DON'T translate this string. Otherwise, +#. "translate" this to "between" in ENGLISH!!! ENGLISH!!! +#: ../gramps/gen/datehandler/_datedisplay.py:426 msgid "between-date|" msgstr "" -#. If there is no special inflection for "and " in your -#. language, don't translate this string. -#. Otherwise, translate it to the ENGLISH!!! ENGLISH!!! -#. key appearing above in the FORMATS_... dict -#. that maps to the special inflected format string that you need to localize. -#: ../gramps/gen/datehandler/_datedisplay.py:383 +#. If there is no special inflection for "and " +#. in your language, DON'T translate this string. Otherwise, +#. "translate" this to "and" in ENGLISH!!! ENGLISH!!! +#: ../gramps/gen/datehandler/_datedisplay.py:431 msgid "and-date|" msgstr "" -#: ../gramps/gen/datehandler/_datedisplay.py:385 +#: ../gramps/gen/datehandler/_datedisplay.py:433 msgid "" "{date_quality}between {date_start} and {date_stop}{nonstd_calendar_and_ny}" msgstr "" @@ -1548,45 +1602,59 @@ msgstr "" #. If there is no special inflection for "before " #. in your language, DON'T translate this string. Otherwise, #. "translate" this to "before" in ENGLISH!!! ENGLISH!!! -#: ../gramps/gen/datehandler/_datedisplay.py:396 +#: ../gramps/gen/datehandler/_datedisplay.py:444 msgid "before-date|" msgstr "" #. If there is no special inflection for "after " #. in your language, DON'T translate this string. Otherwise, #. "translate" this to "after" in ENGLISH!!! ENGLISH!!! -#: ../gramps/gen/datehandler/_datedisplay.py:401 +#: ../gramps/gen/datehandler/_datedisplay.py:449 msgid "after-date|" msgstr "" #. If there is no special inflection for "about " #. in your language, DON'T translate this string. Otherwise, #. "translate" this to "about" in ENGLISH!!! ENGLISH!!! -#: ../gramps/gen/datehandler/_datedisplay.py:406 +#: ../gramps/gen/datehandler/_datedisplay.py:454 msgid "about-date|" msgstr "" -#: ../gramps/gen/datehandler/_datedisplay.py:417 +#. If there is no special inflection for "estimated " +#. in your language, DON'T translate this string. Otherwise, +#. "translate" this to "estimated" in ENGLISH!!! ENGLISH!!! +#: ../gramps/gen/datehandler/_datedisplay.py:459 +msgid "estimated-date|" +msgstr "" + +#. If there is no special inflection for "calculated " +#. in your language, DON'T translate this string. Otherwise, +#. "translate" this to "calculated" in ENGLISH!!! ENGLISH!!! +#: ../gramps/gen/datehandler/_datedisplay.py:464 +msgid "calculated-date|" +msgstr "" + +#: ../gramps/gen/datehandler/_datedisplay.py:483 msgid "{date_quality}{noncompound_modifier}{date}{nonstd_calendar_and_ny}" msgstr "" #. TRANSLATORS: this month is ALREADY inflected: ignore it -#: ../gramps/gen/datehandler/_datedisplay.py:495 +#: ../gramps/gen/datehandler/_datedisplay.py:561 msgid "{long_month} {day:d}, {year}" msgstr "" #. TRANSLATORS: this month is ALREADY inflected: ignore it -#: ../gramps/gen/datehandler/_datedisplay.py:519 +#: ../gramps/gen/datehandler/_datedisplay.py:585 msgid "{short_month} {day:d}, {year}" msgstr "" #. TRANSLATORS: this month is ALREADY inflected: ignore it -#: ../gramps/gen/datehandler/_datedisplay.py:543 +#: ../gramps/gen/datehandler/_datedisplay.py:609 msgid "{day:d} {long_month} {year}" msgstr "" #. TRANSLATORS: this month is ALREADY inflected: ignore it -#: ../gramps/gen/datehandler/_datedisplay.py:567 +#: ../gramps/gen/datehandler/_datedisplay.py:633 msgid "{day:d} {short_month} {year}" msgstr ""