9041: Father/mother's age attributes are not translated on reports

This commit is contained in:
Paul Franklin 2015-11-30 21:49:34 -08:00
parent 20601749e2
commit 4c22713a1a
2 changed files with 53 additions and 47 deletions

View File

@ -2,6 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2015 Paul Franklin
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -58,25 +59,32 @@ class AttributeType(GrampsType):
_CUSTOM = CUSTOM _CUSTOM = CUSTOM
_DEFAULT = ID _DEFAULT = ID
_DATAMAP = [ # _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
(UNKNOWN , _("Unknown"), "Unknown"), def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
(CUSTOM , _("Custom"), "Custom"), return value
(CASTE , _("Caste"), "Caste"),
(DESCRIPTION , _("Description"), "Description"), _BASEMAP = [ # allow deferred translation of attribute UI strings
(ID , _("Identification Number"), "Identification Number"), (UNKNOWN , _T_("Unknown"), "Unknown"),
(NATIONAL , _("National Origin"), "National Origin"), (CUSTOM , _T_("Custom"), "Custom"),
(NUM_CHILD , _("Number of Children"), "Number of Children"), (CASTE , _T_("Caste"), "Caste"),
(SSN , _("Social Security Number"), "Social Security Number"), (DESCRIPTION , _T_("Description"), "Description"),
(NICKNAME , _("Nickname"), "Nickname"), (ID , _T_("Identification Number"), "Identification Number"),
(CAUSE , _("Cause"), "Cause"), (NATIONAL , _T_("National Origin"), "National Origin"),
(AGENCY , _("Agency"), "Agency"), (NUM_CHILD , _T_("Number of Children"), "Number of Children"),
(AGE , _("Age"), "Age"), (SSN , _T_("Social Security Number"),
(FATHER_AGE , _("Father's Age"), "Father Age"), "Social Security Number"),
(MOTHER_AGE , _("Mother's Age"), "Mother Age"), (NICKNAME , _T_("Nickname"), "Nickname"),
(WITNESS , _("Witness"), "Witness"), (CAUSE , _T_("Cause"), "Cause"),
(TIME , _("Time"), "Time"), (AGENCY , _T_("Agency"), "Agency"),
(AGE , _T_("Age"), "Age"),
(FATHER_AGE , _T_("Father's Age"), "Father Age"),
(MOTHER_AGE , _T_("Mother's Age"), "Mother Age"),
(WITNESS , _T_("Witness"), "Witness"),
(TIME , _T_("Time"), "Time"),
] ]
_DATAMAP = [(base[0], _(base[1]), base[2]) for base in _BASEMAP]
def __init__(self, value=None): def __init__(self, value=None):
GrampsType.__init__(self, value) GrampsType.__init__(self, value)
@ -95,3 +103,14 @@ class AttributeType(GrampsType):
""" """
return [] return []
def type2base(self):
"""
Return the untranslated string suitable for UI (once translated).
"""
if self.value == self.CUSTOM:
return str(self)
elif self._BASEMAP[self.value+1]: # UNKNOWN is before CUSTOM, sigh
return self._BASEMAP[self.value+1][1]
else:
return self.UNKNOWN

View File

@ -190,26 +190,8 @@ class IndivCompleteReport(Report):
self.doc.end_superscript() self.doc.end_superscript()
self.doc.end_paragraph() self.doc.end_paragraph()
attr_list = event.get_attribute_list() self.do_attributes(event.get_attribute_list() +
if len(attr_list): event_ref.get_attribute_list() )
for attr in attr_list:
attr_type = self._get_type(attr.get_type())
# translators: needed for French, ignore otherwise
text = self._("%(type)s: %(value)s") % {
'type' : self._(attr_type),
'value' : attr.get_value() }
endnotes = self._cite_endnote(attr)
self.write_paragraph(text, endnotes)
attr_list = event_ref.get_attribute_list()
if len(attr_list):
for attr in attr_list:
# translators: needed for French, ignore otherwise
text = self._("%(type)s: %(value)s") % {
'type' : self._(str(attr.get_type())),
'value' : attr.get_value() }
endnotes = self._cite_endnote(attr)
self.write_paragraph(text, endnotes)
for notehandle in event.get_note_list(): for notehandle in event.get_note_list():
note = self._db.get_note_from_handle(notehandle) note = self._db.get_note_from_handle(notehandle)
@ -413,7 +395,7 @@ class IndivCompleteReport(Report):
self.doc.end_row() self.doc.end_row()
for attr in attr_list: for attr in attr_list:
attr_type = self._get_type(attr.get_type()) attr_type = attr.get_type().type2base()
self.doc.start_row() self.doc.start_row()
self.write_cell(self._(attr_type)) self.write_cell(self._(attr_type))
text = attr.get_value() text = attr.get_value()
@ -547,6 +529,8 @@ class IndivCompleteReport(Report):
self.write_paragraph(description, style='IDS-ImageCaptionCenter') self.write_paragraph(description, style='IDS-ImageCaptionCenter')
ReportUtils.insert_image(self._db, self.doc, media_ref, self._user, ReportUtils.insert_image(self._db, self.doc, media_ref, self._user,
align='center', w_cm=5.0, h_cm=5.0) align='center', w_cm=5.0, h_cm=5.0)
self.do_attributes(media.get_attribute_list() +
media_ref.get_attribute_list() )
self.doc.end_cell() self.doc.end_cell()
if image_count % cells == cells - 1: if image_count % cells == cells - 1:
self.doc.end_row() self.doc.end_row()
@ -620,14 +604,7 @@ class IndivCompleteReport(Report):
self.doc.start_row() self.doc.start_row()
self.write_cell(self._("Attributes")) self.write_cell(self._("Attributes"))
self.doc.start_cell("IDS-ListCell") self.doc.start_cell("IDS-ListCell")
for attr in attr_list: self.do_attributes(attr_list)
attr_type = self._get_type(attr.get_type())
# translators: needed for French, ignore otherwise
text = self._("%(type)s: %(value)s") % {
'type' : self._(attr_type),
'value' : attr.get_value() }
endnotes = self._cite_endnote(attr)
self.write_paragraph(text, endnotes)
self.doc.end_cell() self.doc.end_cell()
self.doc.end_row() self.doc.end_row()
@ -859,7 +836,7 @@ class IndivCompleteReport(Report):
text = _('(image)') text = _('(image)')
else: else:
for attr in attr_list: for attr in attr_list:
attr_type = self._get_type(attr.get_type()) attr_type = attr.get_type().type2base()
# translators: needed for French, ignore otherwise # translators: needed for French, ignore otherwise
text = self._("%(str1)s: %(str2)s") % { text = self._("%(str1)s: %(str2)s") % {
'str1' : self._(attr_type), 'str1' : self._(attr_type),
@ -923,6 +900,16 @@ class IndivCompleteReport(Report):
txt = self._('%(str1)s, %(str2)s') % {'str1':prior, 'str2':txt} txt = self._('%(str1)s, %(str2)s') % {'str1':prior, 'str2':txt}
return txt return txt
def do_attributes(self, attr_list):
for attr in attr_list:
attr_type = attr.get_type().type2base()
# translators: needed for French, ignore otherwise
text = self._("%(type)s: %(value)s") % {
'type' : self._(attr_type),
'value' : attr.get_value() }
endnotes = self._cite_endnote(attr)
self.write_paragraph(text, endnotes)
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# IndivCompleteOptions # IndivCompleteOptions