2371: Make printing reports in different languages easier
svn: r16100
This commit is contained in:
parent
e8883e5b4e
commit
fec4833e24
@ -8,6 +8,7 @@
|
|||||||
# Copyright (C) 2008-2009 James Friedmann <jfriedmannj@gmail.com>
|
# Copyright (C) 2008-2009 James Friedmann <jfriedmannj@gmail.com>
|
||||||
# Copyright (C) 2009 Benny Malengier <benny.malengier@gramps-project.org>
|
# Copyright (C) 2009 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
# Copyright (C) 2010 Jakim Friant
|
# Copyright (C) 2010 Jakim Friant
|
||||||
|
# Copyright (C) 2010 Vlada Peri\u0107
|
||||||
#
|
#
|
||||||
# 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
|
||||||
@ -56,6 +57,8 @@ from gui.plug.report import MenuReportOptions
|
|||||||
import DateHandler
|
import DateHandler
|
||||||
|
|
||||||
from libnarrate import Narrator
|
from libnarrate import Narrator
|
||||||
|
import TransUtils
|
||||||
|
from libtranslate import Translator, get_language_string
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -160,10 +163,17 @@ class DetDescendantReport(Report):
|
|||||||
else:
|
else:
|
||||||
empty_place = ""
|
empty_place = ""
|
||||||
|
|
||||||
|
language = menu.get_option_by_name('trans').get_value()
|
||||||
|
translator = Translator(language)
|
||||||
|
self._ = translator.gettext
|
||||||
|
|
||||||
self.__narrator = Narrator(self.database, self.verbose, use_call, use_fulldate ,
|
self.__narrator = Narrator(self.database, self.verbose, use_call, use_fulldate ,
|
||||||
empty_date, empty_place,
|
empty_date, empty_place,
|
||||||
|
translator=translator,
|
||||||
get_endnote_numbers=self.endnotes)
|
get_endnote_numbers=self.endnotes)
|
||||||
|
|
||||||
|
self.__get_date = translator.get_date
|
||||||
|
|
||||||
self.bibli = Bibliography(Bibliography.MODE_PAGE)
|
self.bibli = Bibliography(Bibliography.MODE_PAGE)
|
||||||
|
|
||||||
def apply_henry_filter(self,person_handle, index, pid, cur_gen=1):
|
def apply_henry_filter(self,person_handle, index, pid, cur_gen=1):
|
||||||
@ -254,7 +264,7 @@ class DetDescendantReport(Report):
|
|||||||
|
|
||||||
self.doc.start_paragraph("DDR-Title")
|
self.doc.start_paragraph("DDR-Title")
|
||||||
|
|
||||||
title = _("Descendant Report for %(person_name)s") % {
|
title = self._("Descendant Report for %(person_name)s") % {
|
||||||
'person_name' : name }
|
'person_name' : name }
|
||||||
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
|
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
|
||||||
self.doc.write_text(title, mark)
|
self.doc.write_text(title, mark)
|
||||||
@ -266,7 +276,7 @@ class DetDescendantReport(Report):
|
|||||||
if self.pgbrk and generation > 0:
|
if self.pgbrk and generation > 0:
|
||||||
self.doc.page_break()
|
self.doc.page_break()
|
||||||
self.doc.start_paragraph("DDR-Generation")
|
self.doc.start_paragraph("DDR-Generation")
|
||||||
text = _("Generation %d") % (generation+1)
|
text = self._("Generation %d") % (generation+1)
|
||||||
mark = IndexMark(text, INDEX_TYPE_TOC, 2)
|
mark = IndexMark(text, INDEX_TYPE_TOC, 2)
|
||||||
self.doc.write_text(text, mark)
|
self.doc.write_text(text, mark)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
@ -348,7 +358,7 @@ class DetDescendantReport(Report):
|
|||||||
if dkey >= key:
|
if dkey >= key:
|
||||||
break
|
break
|
||||||
if self.map[key] == self.map[dkey]:
|
if self.map[key] == self.map[dkey]:
|
||||||
self.doc.write_text(_("%(name)s is the same person as [%(id_str)s].") %
|
self.doc.write_text(self._("%(name)s is the same person as [%(id_str)s].") %
|
||||||
{ 'name' : '', 'id_str' : str(dkey) })
|
{ 'name' : '', 'id_str' : str(dkey) })
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
return
|
return
|
||||||
@ -378,7 +388,7 @@ class DetDescendantReport(Report):
|
|||||||
event = self.database.get_event_from_handle(event_ref.ref)
|
event = self.database.get_event_from_handle(event_ref.ref)
|
||||||
|
|
||||||
if self.fulldate:
|
if self.fulldate:
|
||||||
date = DateHandler.get_date(event)
|
date = self.__get_date(event.get_date_object())
|
||||||
else:
|
else:
|
||||||
date = event.get_date_object().get_year()
|
date = event.get_date_object().get_year()
|
||||||
|
|
||||||
@ -391,12 +401,12 @@ class DetDescendantReport(Report):
|
|||||||
self.doc.start_paragraph('DDR-MoreDetails')
|
self.doc.start_paragraph('DDR-MoreDetails')
|
||||||
event_name = str( event.get_type() )
|
event_name = str( event.get_type() )
|
||||||
if date and place:
|
if date and place:
|
||||||
text += _('%(date)s, %(place)s') % {
|
text += self._('%(date)s, %(place)s') % {
|
||||||
'date' : date, 'place' : place }
|
'date' : date, 'place' : place }
|
||||||
elif date:
|
elif date:
|
||||||
text += _('%(date)s') % {'date' : date}
|
text += self._('%(date)s') % {'date' : date}
|
||||||
elif place:
|
elif place:
|
||||||
text += _('%(place)s') % { 'place' : place }
|
text += self._('%(place)s') % { 'place' : place }
|
||||||
|
|
||||||
if event.get_description():
|
if event.get_description():
|
||||||
if text:
|
if text:
|
||||||
@ -408,8 +418,8 @@ class DetDescendantReport(Report):
|
|||||||
if text:
|
if text:
|
||||||
text += ". "
|
text += ". "
|
||||||
|
|
||||||
text = _('%(event_name)s: %(event_text)s') % {
|
text = self._('%(event_name)s: %(event_text)s') % {
|
||||||
'event_name' : _(event_name),
|
'event_name' : self._(event_name),
|
||||||
'event_text' : text }
|
'event_text' : text }
|
||||||
|
|
||||||
self.doc.write_text_citation(text)
|
self.doc.write_text_citation(text)
|
||||||
@ -421,8 +431,9 @@ class DetDescendantReport(Report):
|
|||||||
for attr in attr_list:
|
for attr in attr_list:
|
||||||
if text:
|
if text:
|
||||||
text += "; "
|
text += "; "
|
||||||
text += _("%(type)s: %(value)s%(endnotes)s") % {
|
attrName = str(attr.get_type())
|
||||||
'type' : attr.get_type(),
|
text += self._("%(type)s: %(value)s%(endnotes)s") % {
|
||||||
|
'type' : self._(attrName),
|
||||||
'value' : attr.get_value(),
|
'value' : attr.get_value(),
|
||||||
'endnotes' : self.endnotes(attr) }
|
'endnotes' : self.endnotes(attr) }
|
||||||
text = " " + text
|
text = " " + text
|
||||||
@ -503,9 +514,9 @@ class DetDescendantReport(Report):
|
|||||||
name = _nd.display_formal(mate)
|
name = _nd.display_formal(mate)
|
||||||
mark = ReportUtils.get_person_mark(self.database, mate)
|
mark = ReportUtils.get_person_mark(self.database, mate)
|
||||||
if family.get_relationship() == FamilyRelType.MARRIED:
|
if family.get_relationship() == FamilyRelType.MARRIED:
|
||||||
self.doc.write_text(_("Spouse: %s") % name, mark)
|
self.doc.write_text(self._("Spouse: %s") % name, mark)
|
||||||
else:
|
else:
|
||||||
self.doc.write_text(_("Relationship with: %s") % name, mark)
|
self.doc.write_text(self._("Relationship with: %s") % name, mark)
|
||||||
if name[-1:] != '.':
|
if name[-1:] != '.':
|
||||||
self.doc.write_text(".")
|
self.doc.write_text(".")
|
||||||
self.doc.write_text_citation(self.endnotes(mate))
|
self.doc.write_text_citation(self.endnotes(mate))
|
||||||
@ -519,14 +530,14 @@ class DetDescendantReport(Report):
|
|||||||
mother = self.database.get_person_from_handle(mother_handle)
|
mother = self.database.get_person_from_handle(mother_handle)
|
||||||
mother_name = _nd.display(mother)
|
mother_name = _nd.display(mother)
|
||||||
else:
|
else:
|
||||||
mother_name = _("unknown")
|
mother_name = self._("unknown")
|
||||||
|
|
||||||
father_handle = family.get_father_handle()
|
father_handle = family.get_father_handle()
|
||||||
if father_handle:
|
if father_handle:
|
||||||
father = self.database.get_person_from_handle(father_handle)
|
father = self.database.get_person_from_handle(father_handle)
|
||||||
father_name = _nd.display(father)
|
father_name = _nd.display(father)
|
||||||
else:
|
else:
|
||||||
father_name = _("unknown")
|
father_name = self._("unknown")
|
||||||
|
|
||||||
return mother_name, father_name
|
return mother_name, father_name
|
||||||
|
|
||||||
@ -541,7 +552,7 @@ class DetDescendantReport(Report):
|
|||||||
|
|
||||||
self.doc.start_paragraph("DDR-ChildTitle")
|
self.doc.start_paragraph("DDR-ChildTitle")
|
||||||
self.doc.write_text(
|
self.doc.write_text(
|
||||||
_("Children of %(mother_name)s and %(father_name)s") %
|
self._("Children of %(mother_name)s and %(father_name)s") %
|
||||||
{'father_name': father_name,
|
{'father_name': father_name,
|
||||||
'mother_name': mother_name
|
'mother_name': mother_name
|
||||||
} )
|
} )
|
||||||
@ -599,7 +610,7 @@ class DetDescendantReport(Report):
|
|||||||
|
|
||||||
self.doc.start_paragraph("DDR-NoteHeader")
|
self.doc.start_paragraph("DDR-NoteHeader")
|
||||||
self.doc.write_text(
|
self.doc.write_text(
|
||||||
_('Notes for %(mother_name)s and %(father_name)s:') % {
|
self._('Notes for %(mother_name)s and %(father_name)s:') % {
|
||||||
'mother_name' : mother_name,
|
'mother_name' : mother_name,
|
||||||
'father_name' : father_name })
|
'father_name' : father_name })
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
@ -622,7 +633,7 @@ class DetDescendantReport(Report):
|
|||||||
if first:
|
if first:
|
||||||
self.doc.start_paragraph('DDR-MoreHeader')
|
self.doc.start_paragraph('DDR-MoreHeader')
|
||||||
self.doc.write_text(
|
self.doc.write_text(
|
||||||
_('More about %(mother_name)s and %(father_name)s:') % {
|
self._('More about %(mother_name)s and %(father_name)s:') % {
|
||||||
'mother_name' : mother_name,
|
'mother_name' : mother_name,
|
||||||
'father_name' : father_name })
|
'father_name' : father_name })
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
@ -641,14 +652,14 @@ class DetDescendantReport(Report):
|
|||||||
|
|
||||||
self.doc.start_paragraph('DDR-MoreHeader')
|
self.doc.start_paragraph('DDR-MoreHeader')
|
||||||
self.doc.write_text(
|
self.doc.write_text(
|
||||||
_('More about %(mother_name)s and %(father_name)s:') % {
|
self._('More about %(mother_name)s and %(father_name)s:') % {
|
||||||
'mother_name' : mother_name,
|
'mother_name' : mother_name,
|
||||||
'father_name' : father_name })
|
'father_name' : father_name })
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
|
|
||||||
for attr in attrs:
|
for attr in attrs:
|
||||||
self.doc.start_paragraph('DDR-MoreDetails')
|
self.doc.start_paragraph('DDR-MoreDetails')
|
||||||
text = _("%(type)s: %(value)s%(endnotes)s") % {
|
text = self._("%(type)s: %(value)s%(endnotes)s") % {
|
||||||
'type' : attr.get_type(),
|
'type' : attr.get_type(),
|
||||||
'value' : attr.get_value(),
|
'value' : attr.get_value(),
|
||||||
'endnotes' : self.endnotes(attr) }
|
'endnotes' : self.endnotes(attr) }
|
||||||
@ -707,7 +718,7 @@ class DetDescendantReport(Report):
|
|||||||
notelist = person.get_note_list()
|
notelist = person.get_note_list()
|
||||||
if len(notelist) > 0 and self.inc_notes:
|
if len(notelist) > 0 and self.inc_notes:
|
||||||
self.doc.start_paragraph("DDR-NoteHeader")
|
self.doc.start_paragraph("DDR-NoteHeader")
|
||||||
self.doc.write_text(_("Notes for %s") % name)
|
self.doc.write_text(self._("Notes for %s") % name)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
for notehandle in notelist:
|
for notehandle in notelist:
|
||||||
note = self.database.get_note_from_handle(notehandle)
|
note = self.database.get_note_from_handle(notehandle)
|
||||||
@ -720,14 +731,14 @@ class DetDescendantReport(Report):
|
|||||||
for alt_name in person.get_alternate_names():
|
for alt_name in person.get_alternate_names():
|
||||||
if first:
|
if first:
|
||||||
self.doc.start_paragraph('DDR-MoreHeader')
|
self.doc.start_paragraph('DDR-MoreHeader')
|
||||||
self.doc.write_text(_('More about %(person_name)s:') % {
|
self.doc.write_text(self._('More about %(person_name)s:') % {
|
||||||
'person_name' : name })
|
'person_name' : name })
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
first = False
|
first = False
|
||||||
self.doc.start_paragraph('DDR-MoreDetails')
|
self.doc.start_paragraph('DDR-MoreDetails')
|
||||||
atype = str( alt_name.get_type() )
|
atype = str( alt_name.get_type() )
|
||||||
aname = alt_name.get_regular_name()
|
aname = alt_name.get_regular_name()
|
||||||
self.doc.write_text_citation(_('%(name_kind)s: %(name)s%(endnotes)s') % {
|
self.doc.write_text_citation(self._('%(name_kind)s: %(name)s%(endnotes)s') % {
|
||||||
'name_kind' : atype,
|
'name_kind' : atype,
|
||||||
'name' : aname,
|
'name' : aname,
|
||||||
'endnotes' : self.endnotes(alt_name),
|
'endnotes' : self.endnotes(alt_name),
|
||||||
@ -738,7 +749,7 @@ class DetDescendantReport(Report):
|
|||||||
for event_ref in person.get_primary_event_ref_list():
|
for event_ref in person.get_primary_event_ref_list():
|
||||||
if first:
|
if first:
|
||||||
self.doc.start_paragraph('DDR-MoreHeader')
|
self.doc.start_paragraph('DDR-MoreHeader')
|
||||||
self.doc.write_text(_('More about %(person_name)s:') % {
|
self.doc.write_text(self._('More about %(person_name)s:') % {
|
||||||
'person_name' : _nd.display(person) })
|
'person_name' : _nd.display(person) })
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
first = 0
|
first = 0
|
||||||
@ -749,7 +760,7 @@ class DetDescendantReport(Report):
|
|||||||
for addr in person.get_address_list():
|
for addr in person.get_address_list():
|
||||||
if first:
|
if first:
|
||||||
self.doc.start_paragraph('DDR-MoreHeader')
|
self.doc.start_paragraph('DDR-MoreHeader')
|
||||||
self.doc.write_text(_('More about %(person_name)s:') % {
|
self.doc.write_text(self._('More about %(person_name)s:') % {
|
||||||
'person_name' : name })
|
'person_name' : name })
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
first = False
|
first = False
|
||||||
@ -758,11 +769,11 @@ class DetDescendantReport(Report):
|
|||||||
text = ReportUtils.get_address_str(addr)
|
text = ReportUtils.get_address_str(addr)
|
||||||
|
|
||||||
if self.fulldate:
|
if self.fulldate:
|
||||||
date = DateHandler.get_date(addr)
|
date = self.__get_date(addr.get_date_object())
|
||||||
else:
|
else:
|
||||||
date = addr.get_date_object().get_year()
|
date = addr.get_date_object().get_year()
|
||||||
|
|
||||||
self.doc.write_text(_('Address: '))
|
self.doc.write_text(self._('Address: '))
|
||||||
if date:
|
if date:
|
||||||
self.doc.write_text( '%s, ' % date )
|
self.doc.write_text( '%s, ' % date )
|
||||||
self.doc.write_text( text )
|
self.doc.write_text( text )
|
||||||
@ -773,14 +784,14 @@ class DetDescendantReport(Report):
|
|||||||
attrs = person.get_attribute_list()
|
attrs = person.get_attribute_list()
|
||||||
if first and attrs:
|
if first and attrs:
|
||||||
self.doc.start_paragraph('DDR-MoreHeader')
|
self.doc.start_paragraph('DDR-MoreHeader')
|
||||||
self.doc.write_text(_('More about %(person_name)s:') % {
|
self.doc.write_text(self._('More about %(person_name)s:') % {
|
||||||
'person_name' : name })
|
'person_name' : name })
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
first = False
|
first = False
|
||||||
|
|
||||||
for attr in attrs:
|
for attr in attrs:
|
||||||
self.doc.start_paragraph('DDR-MoreDetails')
|
self.doc.start_paragraph('DDR-MoreDetails')
|
||||||
text = _("%(type)s: %(value)s%(endnotes)s") % {
|
text = self._("%(type)s: %(value)s%(endnotes)s") % {
|
||||||
'type' : attr.get_type(),
|
'type' : attr.get_type(),
|
||||||
'value' : attr.get_value(),
|
'value' : attr.get_value(),
|
||||||
'endnotes' : self.endnotes(attr) }
|
'endnotes' : self.endnotes(attr) }
|
||||||
@ -844,6 +855,14 @@ class DetDescendantOptions(MenuReportOptions):
|
|||||||
_("Whether to start a new page before the end notes."))
|
_("Whether to start a new page before the end notes."))
|
||||||
menu.add_option(category_name,"pageben",pageben)
|
menu.add_option(category_name,"pageben",pageben)
|
||||||
|
|
||||||
|
trans = EnumeratedListOption(_("Translation"),
|
||||||
|
Translator.DEFAULT_TRANSLATION_STR)
|
||||||
|
trans.add_item(Translator.DEFAULT_TRANSLATION_STR, _("default"))
|
||||||
|
for language in TransUtils.get_available_translations():
|
||||||
|
trans.add_item(language, get_language_string(language))
|
||||||
|
trans.set_help(_("The translation to be used for the report."))
|
||||||
|
menu.add_option(category_name, "trans", trans)
|
||||||
|
|
||||||
category_name = _("Content")
|
category_name = _("Content")
|
||||||
|
|
||||||
usecall = BooleanOption(_("Use callname for common name"), False)
|
usecall = BooleanOption(_("Use callname for common name"), False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user