Setting the year as an ordinal number in Croatian

With this commit, two more reports now show a year as an
ordinal number in Croatian, and a year I missed before in
webcal.py is now fixed.

This commit also reverts the Croatian ordinal year fix in
the gramps50 statisticschart.py since upon reflection I
feel it would be better done in master, since then our
translators will have until 5.1.0 is released to do the
two new strings the fix requires.

Issue #10822
This commit is contained in:
Paul Franklin 2018-10-07 23:43:36 -07:00
parent 01060f0b0d
commit 375773d657
4 changed files with 26 additions and 13 deletions

View File

@ -421,7 +421,7 @@ class Extract:
if date: if date:
year = date.get_year() year = date.get_year()
if year: if year:
return [self._get_date(Date(year))] # localized year return [str(year)]
return [_T_("Date(s) missing")] return [_T_("Date(s) missing")]
def get_month(self, event): def get_month(self, event):
@ -672,7 +672,6 @@ class Extract:
self._locale = rlocale self._locale = rlocale
self._ = rlocale.translation.sgettext self._ = rlocale.translation.sgettext
self._get_type = rlocale.get_type self._get_type = rlocale.get_type
self._get_date = rlocale.get_date
data = [] data = []
ext = self.extractors ext = self.extractors
@ -789,12 +788,21 @@ class StatisticsChart(Report):
else: else:
genders = None genders = None
# needed for keyword based localization
mapping = {
'genders': genders,
'year_from': year_from,
'year_to': year_to
}
if genders: if genders:
span_string = self._("%s born") % genders span_string = self._("%(genders)s born "
"%(year_from)04d-%(year_to)04d"
) % mapping
else: else:
span_string = self._("Persons born") span_string = self._("Persons born "
span_string += " %s-%s" % (self._get_date(Date(year_from)), # localized "%(year_from)04d-%(year_to)04d"
self._get_date(Date(year_to))) ) % mapping
people = self.filter.apply(self.database, people = self.filter.apply(self.database,
self.database.iter_person_handles(), self.database.iter_person_handles(),

View File

@ -49,7 +49,7 @@ LOG = logging.getLogger(".FamilyLines")
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
from gramps.gen.lib import EventRoleType, EventType, Person, PlaceType from gramps.gen.lib import EventRoleType, EventType, Person, PlaceType, Date
from gramps.gen.utils.file import media_path_full from gramps.gen.utils.file import media_path_full
from gramps.gen.utils.thumbnails import (get_thumbnail_path, SIZE_NORMAL, from gramps.gen.utils.thumbnails import (get_thumbnail_path, SIZE_NORMAL,
SIZE_LARGE) SIZE_LARGE)
@ -811,7 +811,8 @@ class FamilyLinesReport(Report):
if bth_event and self._incdates: if bth_event and self._incdates:
date = bth_event.get_date_object() date = bth_event.get_date_object()
if self._just_years and date.get_year_valid(): if self._just_years and date.get_year_valid():
birth_str = '%i' % date.get_year() birth_str = self._get_date( # localized year
Date(date.get_year()))
else: else:
birth_str = self._get_date(date) birth_str = self._get_date(date)
@ -826,7 +827,8 @@ class FamilyLinesReport(Report):
if dth_event and self._incdates: if dth_event and self._incdates:
date = dth_event.get_date_object() date = dth_event.get_date_object()
if self._just_years and date.get_year_valid(): if self._just_years and date.get_year_valid():
death_str = '%i' % date.get_year() death_str = self._get_date( # localized year
Date(date.get_year()))
else: else:
death_str = self._get_date(date) death_str = self._get_date(date)
@ -953,7 +955,8 @@ class FamilyLinesReport(Report):
if self._incdates: if self._incdates:
date = event.get_date_object() date = event.get_date_object()
if self._just_years and date.get_year_valid(): if self._just_years and date.get_year_valid():
wedding_date = '%i' % date.get_year() wedding_date = self._get_date( # localized year
Date(date.get_year()))
else: else:
wedding_date = self._get_date(date) wedding_date = self._get_date(date)
# get the wedding location # get the wedding location

View File

@ -54,7 +54,7 @@ from gramps.gen.plug.report import Report
from gramps.gen.plug.report import utils from gramps.gen.plug.report import utils
from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions from gramps.gen.plug.report import stdoptions
from gramps.gen.lib import ChildRefType, EventRoleType, EventType from gramps.gen.lib import ChildRefType, EventRoleType, EventType, Date
from gramps.gen.utils.file import media_path_full, find_file from gramps.gen.utils.file import media_path_full, find_file
from gramps.gen.utils.thumbnails import get_thumbnail_path from gramps.gen.utils.thumbnails import get_thumbnail_path
from gramps.gen.relationship import get_relationship_calculator from gramps.gen.relationship import get_relationship_calculator
@ -718,7 +718,8 @@ class RelGraphReport(Report):
event_date = event.get_date_object() event_date = event.get_date_object()
if event_date.get_year_valid(): if event_date.get_year_valid():
if self.event_choice in [4, 5]: if self.event_choice in [4, 5]:
return '%i' % event_date.get_year() return self._get_date( # localized year
Date(event_date.get_year()))
elif self.event_choice in [1, 2, 3, 7]: elif self.event_choice in [1, 2, 3, 7]:
return self._get_date(event_date) return self._get_date(event_date)
return '' return ''

View File

@ -708,7 +708,8 @@ class WebCalReport(Report):
th_txt = month_name th_txt = month_name
if cal == 'wc': # webcalendar() if cal == 'wc': # webcalendar()
if not self.multiyear: if not self.multiyear:
th_txt = '%s %04d' % (month_name, year) th_txt = '%s %s' % (month_name,
self._get_date(Date(year))) # localized
# begin calendar table and table head # begin calendar table and table head
with Html("table", class_="calendar", with Html("table", class_="calendar",