From 54be8d62f31fa5baf997f77395388ede100fcd3e Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Thu, 4 Oct 2018 09:21:29 -0700 Subject: [PATCH] Setting the year as an ordinal number in Croatian With this commit, three more reports now show a year as an ordinal number in Croatian. Issue #10822 --- gramps/plugins/drawreport/fanchart.py | 8 +++++--- gramps/plugins/drawreport/statisticschart.py | 20 ++++++-------------- gramps/plugins/drawreport/timeline.py | 3 ++- po/hr.po | 2 +- 4 files changed, 14 insertions(+), 19 deletions(-) diff --git a/gramps/plugins/drawreport/fanchart.py b/gramps/plugins/drawreport/fanchart.py index b94ea9329..25c7c02df 100644 --- a/gramps/plugins/drawreport/fanchart.py +++ b/gramps/plugins/drawreport/fanchart.py @@ -57,7 +57,7 @@ from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import stdoptions from gramps.gen.config import config from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback -from gramps.gen.lib import EventType +from gramps.gen.lib import EventType, Date from gramps.gen.proxy import CacheProxyDb from gramps.gen.display.name import displayer as _nd @@ -329,7 +329,8 @@ class FanChart(Report): bth = "" if birth: bth = birth.get_date_object() - bth = str(bth.to_calendar(self.calendar).get_year()) + bth = self._get_date( + Date(bth.to_calendar(self.calendar).get_year())) # localized if bth == 0: bth = "" elif birth.get_type() != EventType.BIRTH: @@ -339,7 +340,8 @@ class FanChart(Report): dth = "" if death: dth = death.get_date_object() - dth = str(dth.to_calendar(self.calendar).get_year()) + dth = self._get_date( + Date(dth.to_calendar(self.calendar).get_year())) # localized if dth == 0: dth = "" elif death.get_type() != EventType.DEATH: diff --git a/gramps/plugins/drawreport/statisticschart.py b/gramps/plugins/drawreport/statisticschart.py index f631ffcb6..6bd5fa884 100644 --- a/gramps/plugins/drawreport/statisticschart.py +++ b/gramps/plugins/drawreport/statisticschart.py @@ -421,7 +421,7 @@ class Extract: if date: year = date.get_year() if year: - return [str(year)] + return [self._get_date(Date(year))] # localized year return [_T_("Date(s) missing")] def get_month(self, event): @@ -672,6 +672,7 @@ class Extract: self._locale = rlocale self._ = rlocale.translation.sgettext self._get_type = rlocale.get_type + self._get_date = rlocale.get_date data = [] ext = self.extractors @@ -788,21 +789,12 @@ class StatisticsChart(Report): else: genders = None - # needed for keyword based localization - mapping = { - 'genders': genders, - 'year_from': year_from, - 'year_to': year_to - } - if genders: - span_string = self._("%(genders)s born " - "%(year_from)04d-%(year_to)04d" - ) % mapping + span_string = self._("%s born") % genders else: - span_string = self._("Persons born " - "%(year_from)04d-%(year_to)04d" - ) % mapping + span_string = self._("Persons born") + span_string += " %s-%s" % (self._get_date(Date(year_from)), # localized + self._get_date(Date(year_to))) people = self.filter.apply(self.database, self.database.iter_person_handles(), diff --git a/gramps/plugins/drawreport/timeline.py b/gramps/plugins/drawreport/timeline.py index 27764f163..d621cf3b7 100644 --- a/gramps/plugins/drawreport/timeline.py +++ b/gramps/plugins/drawreport/timeline.py @@ -45,6 +45,7 @@ from gramps.gen.sort import Sort from gramps.gen.config import config from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback from gramps.gen.proxy import CacheProxyDb +from gramps.gen.lib import Date #------------------------------------------------------------------------ # @@ -297,7 +298,7 @@ class TimeLine(Report): delta = (stop_pos - start_pos) / 5 for val in range(0, 6): xpos = start_pos + (val * delta) - year_str = str(int(year_low + (incr * val))) + year_str = self._get_date(Date(year_low + int(incr * val))) self.doc.center_text('TLG-label', year_str, xpos, label_y) def draw_no_date_heading(self): diff --git a/po/hr.po b/po/hr.po index 530b46c77..e8ebd3b25 100644 --- a/po/hr.po +++ b/po/hr.po @@ -20981,7 +20981,7 @@ msgstr "Spremanje dijagrama..." #: ../gramps/plugins/drawreport/statisticschart.py:939 #, python-format msgid "%s (persons):" -msgstr "%s (persons):" +msgstr "%s (osobe):" #: ../gramps/plugins/drawreport/statisticschart.py:991 #: ../gramps/plugins/textreport/recordsreport.py:219