add Gramps type name on translator class

svn: r16113
This commit is contained in:
Jérôme Rapinat 2010-11-02 15:05:51 +00:00
parent bf042a6934
commit 2c37a2c7bb
3 changed files with 30 additions and 11 deletions

View File

@ -40,6 +40,7 @@ _ = gettext.gettext
import TransUtils
import DateHandler
import config
from gen.lib.grampstype import GrampsType
#------------------------------------------------------------------------
#
@ -221,3 +222,14 @@ class Translator:
:rtype: unicode
"""
return self.__dd.display(date)
def get_type(self, name):
"""
Return a string representing the name appropriate for the language being
translated.
:param name: The name type to be represented.
:returns: The name as text in the proper language.
:rtype: unicode
"""
return GrampsType.xml_str(name)

View File

@ -157,6 +157,8 @@ class DetAncestorReport(Report):
self.__get_date = translator.get_date
self.__get_type = translator.get_type
self.bibli = Bibliography(Bibliography.MODE_PAGE)
def apply_filter(self, person_handle, index):
@ -219,6 +221,7 @@ class DetAncestorReport(Report):
if self.inc_sources:
if self.pgbrkenotes:
self.doc.page_break()
# it ignores language set for Note type (use locale)
endnotes.write_endnotes(self.bibli, self.database, self.doc,
printnotes=self.inc_srcnotes)
@ -314,10 +317,10 @@ class DetAncestorReport(Report):
self.doc.end_paragraph()
first = False
self.doc.start_paragraph('DAR-MoreDetails')
atype = str( alt_name.get_type() )
atype = self.__get_type(alt_name.get_type())
self.doc.write_text_citation(
self._('%(name_kind)s: %(name)s%(endnotes)s') % {
'name_kind' : atype,
'name_kind' : self._(atype),
'name' : alt_name.get_regular_name(),
'endnotes' : self.endnotes(alt_name),
})
@ -374,7 +377,7 @@ class DetAncestorReport(Report):
for attr in attrs:
self.doc.start_paragraph('DAR-MoreDetails')
attrName = str(attr.get_type())
attrName = self.__get_type(attr.get_type())
text = self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attrName),
'value' : attr.get_value(),
@ -400,7 +403,7 @@ class DetAncestorReport(Report):
place = u''
self.doc.start_paragraph('DAR-MoreDetails')
evtName = str( event.get_type() )
evtName = self.__get_type(event.get_type())
if date and place:
text += self._('%(date)s, %(place)s') % {
'date' : date, 'place' : place }
@ -432,7 +435,7 @@ class DetAncestorReport(Report):
for attr in attr_list:
if text:
text += "; "
attrName = str(attr.get_type())
attrName = self.__get_type(attr.get_type())
text += self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attrName),
'value' : attr.get_value(),

View File

@ -174,6 +174,8 @@ class DetDescendantReport(Report):
self.__get_date = translator.get_date
self.__get_type = translator.get_type
self.bibli = Bibliography(Bibliography.MODE_PAGE)
def apply_henry_filter(self,person_handle, index, pid, cur_gen=1):
@ -292,6 +294,7 @@ class DetDescendantReport(Report):
if self.inc_sources:
if self.pgbrkenotes:
self.doc.page_break()
# it ignores language set for Note type (use locale)
endnotes.write_endnotes(self.bibli, self.database, self.doc,
printnotes=self.inc_srcnotes)
@ -399,7 +402,7 @@ class DetDescendantReport(Report):
place = u''
self.doc.start_paragraph('DDR-MoreDetails')
event_name = str( event.get_type() )
event_name = self.__get_type(event.get_type())
if date and place:
text += self._('%(date)s, %(place)s') % {
'date' : date, 'place' : place }
@ -431,7 +434,7 @@ class DetDescendantReport(Report):
for attr in attr_list:
if text:
text += "; "
attrName = str(attr.get_type())
attrName = self.__get_type(attr.get_type())
text += self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attrName),
'value' : attr.get_value(),
@ -659,7 +662,7 @@ class DetDescendantReport(Report):
for attr in attrs:
self.doc.start_paragraph('DDR-MoreDetails')
attrName = str(attr.get_type())
attrName = self.__get_type(attr.get_type())
text = self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : self._(attrName),
'value' : attr.get_value(),
@ -737,10 +740,10 @@ class DetDescendantReport(Report):
self.doc.end_paragraph()
first = False
self.doc.start_paragraph('DDR-MoreDetails')
atype = str( alt_name.get_type() )
atype = self.__get_type(alt_name.get_type())
aname = alt_name.get_regular_name()
self.doc.write_text_citation(self._('%(name_kind)s: %(name)s%(endnotes)s') % {
'name_kind' : atype,
'name_kind' : self._(atype),
'name' : aname,
'endnotes' : self.endnotes(alt_name),
})
@ -792,8 +795,9 @@ class DetDescendantReport(Report):
for attr in attrs:
self.doc.start_paragraph('DDR-MoreDetails')
attrName = self.__get_type(attr.get_type())
text = self._("%(type)s: %(value)s%(endnotes)s") % {
'type' : attr.get_type(),
'type' : self._(attrName),
'value' : attr.get_value(),
'endnotes' : self.endnotes(attr) }
self.doc.write_text_citation( text )