enable translated output for this report

svn: r22079
This commit is contained in:
Paul Franklin 2013-04-23 04:51:54 +00:00
parent 5c13786ac4
commit 4dd28d5532

View File

@ -4,6 +4,7 @@
# Copyright (C) 2008,2011 Gary Burton # Copyright (C) 2008,2011 Gary Burton
# Copyright (C) 2010 Jakim Friant # Copyright (C) 2010 Jakim Friant
# Copyright (C) 2011 Heinz Brinker # Copyright (C) 2011 Heinz Brinker
# Copyright (C) 2013 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
@ -29,21 +30,23 @@
# python modules # python modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #
# gramps modules # gramps modules
# #
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug.menu import FilterOption, PlaceListOption, EnumeratedListOption, \ from gramps.gen.const import GRAMPS_LOCALE as glocale
BooleanOption _ = glocale.translation.gettext
from gramps.gen.plug.menu import (FilterOption, PlaceListOption,
EnumeratedListOption, BooleanOption)
from gramps.gen.plug.report import Report from gramps.gen.plug.report import Report
from gramps.gen.plug.report import MenuReportOptions from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle, TableStyle, from gramps.gen.plug.report import stdoptions
TableCellStyle, FONT_SANS_SERIF, FONT_SERIF, from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER) TableStyle, TableCellStyle,
FONT_SANS_SERIF, FONT_SERIF,
INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
from gramps.gen.proxy import PrivateProxyDb from gramps.gen.proxy import PrivateProxyDb
from gramps.gen.datehandler import get_date from gramps.gen.datehandler import get_date
from gramps.gen.sort import Sort from gramps.gen.sort import Sort
@ -80,12 +83,13 @@ class PlaceReport(Report):
self.center = menu.get_option_by_name('center').get_value() self.center = menu.get_option_by_name('center').get_value()
self.incpriv = menu.get_option_by_name('incpriv').get_value() self.incpriv = menu.get_option_by_name('incpriv').get_value()
self.set_locale(menu.get_option_by_name('trans').get_value())
if self.incpriv: if self.incpriv:
self.database = database self.database = database
else: else:
self.database = PrivateProxyDb(database) self.database = PrivateProxyDb(database)
filter_option = menu.get_option_by_name('filter') filter_option = menu.get_option_by_name('filter')
self.filter = filter_option.get_filter() self.filter = filter_option.get_filter()
self.sort = Sort(self.database) self.sort = Sort(self.database)
@ -102,14 +106,14 @@ class PlaceReport(Report):
def write_report(self): def write_report(self):
""" """
The routine the actually creates the report. At this point, the document The routine that actually creates the report.
is opened and ready for writing. At this point, the document is opened and ready for writing.
""" """
# Write the title line. Set in INDEX marker so that this section will be # Write the title line. Set in INDEX marker so that this section will be
# identified as a major category if this is included in a Book report. # identified as a major category if this is included in a Book report.
title = _("Place Report") title = self._("Place Report")
mark = IndexMark(title, INDEX_TYPE_TOC, 1) mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.start_paragraph("PLC-ReportTitle") self.doc.start_paragraph("PLC-ReportTitle")
self.doc.write_text(title, mark) self.doc.write_text(title, mark)
@ -147,14 +151,14 @@ class PlaceReport(Report):
place = self.database.get_place_from_handle(handle) place = self.database.get_place_from_handle(handle)
location = place.get_main_location() location = place.get_main_location()
place_details = [_("Gramps ID: %s ") % place.get_gramps_id(), place_details = [self._("Gramps ID: %s ") % place.get_gramps_id(),
_("Street: %s ") % location.get_street(), self._("Street: %s ") % location.get_street(),
_("Parish: %s ") % location.get_parish(), self._("Parish: %s ") % location.get_parish(),
_("Locality: %s ") % location.get_locality(), self._("Locality: %s ") % location.get_locality(),
_("City: %s ") % location.get_city(), self._("City: %s ") % location.get_city(),
_("County: %s ") % location.get_county(), self._("County: %s ") % location.get_county(),
_("State: %s") % location.get_state(), self._("State: %s") % location.get_state(),
_("Country: %s ") % location.get_country()] self._("Country: %s ") % location.get_country()]
self.doc.start_paragraph("PLC-PlaceTitle") self.doc.start_paragraph("PLC-PlaceTitle")
self.doc.write_text(("%(nbr)s. %(place)s") % self.doc.write_text(("%(nbr)s. %(place)s") %
{'nbr' : place_nbr, {'nbr' : place_nbr,
@ -176,12 +180,12 @@ class PlaceReport(Report):
if event_handles: if event_handles:
self.doc.start_paragraph("PLC-Section") self.doc.start_paragraph("PLC-Section")
title = _("Events that happened at this place") title = self._("Events that happened at this place")
self.doc.write_text(title) self.doc.write_text(title)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table("EventTable", "PLC-EventTable") self.doc.start_table("EventTable", "PLC-EventTable")
column_titles = [_("Date"), _("Type of Event"), column_titles = [self._("Date"), self._("Type of Event"),
_("Person"), _("Description")] self._("Person"), self._("Description")]
self.doc.start_row() self.doc.start_row()
for title in column_titles: for title in column_titles:
self.doc.start_cell("PLC-TableColumn") self.doc.start_cell("PLC-TableColumn")
@ -223,8 +227,10 @@ class PlaceReport(Report):
% {'name': _nd.display(person), % {'name': _nd.display(person),
'id': person.get_gramps_id()} 'id': person.get_gramps_id()}
else: else:
people = _("%(persons)s and %(name)s (%(id)s)") \ people = self._("%(persons)s and %(name)s "
% {'persons': people, 'name': _nd.display(person), "(%(id)s)") \
% {'persons': people,
'name': _nd.display(person),
'id': person.get_gramps_id()} 'id': person.get_gramps_id()}
event_details = [date, event_type, people, descr] event_details = [date, event_type, people, descr]
@ -249,12 +255,12 @@ class PlaceReport(Report):
if event_handles: if event_handles:
self.doc.start_paragraph("PLC-Section") self.doc.start_paragraph("PLC-Section")
title = _("People associated with this place") title = self._("People associated with this place")
self.doc.write_text(title) self.doc.write_text(title)
self.doc.end_paragraph() self.doc.end_paragraph()
self.doc.start_table("EventTable", "PLC-PersonTable") self.doc.start_table("EventTable", "PLC-PersonTable")
column_titles = [_("Person"), _("Type of Event"), \ column_titles = [self._("Person"), self._("Type of Event"), \
_("Description"), _("Date")] self._("Description"), self._("Date")]
self.doc.start_row() self.doc.start_row()
for title in column_titles: for title in column_titles:
self.doc.start_cell("PLC-TableColumn") self.doc.start_cell("PLC-TableColumn")
@ -285,11 +291,12 @@ class PlaceReport(Report):
if f_handle and m_handle: if f_handle and m_handle:
father = self.database.get_person_from_handle(f_handle) father = self.database.get_person_from_handle(f_handle)
mother = self.database.get_person_from_handle(m_handle) mother = self.database.get_person_from_handle(m_handle)
nameEntry = "%s (%s) and %s (%s)" % \ nameEntry = self._("%(father)s (%(father_id)s) and "
(_nd.display(father), "%(mother)s (%(mother_id)s)") % \
father.get_gramps_id(), { 'father' : _nd.display(father),
_nd.display(mother), 'father_id' : father.get_gramps_id(),
mother.get_gramps_id()) 'mother' : _nd.display(mother),
'mother_id' : mother.get_gramps_id()}
else: else:
if f_handle: if f_handle:
p_handle = f_handle p_handle = f_handle
@ -393,6 +400,8 @@ class PlaceOptions(MenuReportOptions):
incpriv.set_help(_("Whether to include private data")) incpriv.set_help(_("Whether to include private data"))
menu.add_option(category_name, "incpriv", incpriv) menu.add_option(category_name, "incpriv", incpriv)
stdoptions.add_localization_option(menu, category_name)
def make_default_style(self, default_style): def make_default_style(self, default_style):
""" """
Make the default output style for the Place report. Make the default output style for the Place report.