enable translated output for this report
svn: r22118
This commit is contained in:
parent
70ee3d822f
commit
6ea9a5ad70
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2013 Paul Franklin
|
||||
#
|
||||
# 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
|
||||
@ -190,53 +191,56 @@ class EventType(GrampsType):
|
||||
(MARR_ALT , _("Alternate Marriage"), "Alternate Marriage"),
|
||||
]
|
||||
|
||||
def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
|
||||
return value
|
||||
|
||||
_ABBREVIATIONS = {
|
||||
BIRTH: _("birth abbreviation|b."),
|
||||
DEATH: _("death abbreviation|d."),
|
||||
MARRIAGE: _("marriage abbreviation|m."),
|
||||
UNKNOWN: _("Unknown abbreviation|unkn."),
|
||||
CUSTOM: _("Custom abbreviation|cust."),
|
||||
ADOPT: _("Adopted abbreviation|adop."),
|
||||
ADULT_CHRISTEN : _("Adult Christening abbreviation|a.chr."),
|
||||
BAPTISM: _("Baptism abbreviation|bap."),
|
||||
BAR_MITZVAH : _("Bar Mitzvah abbreviation|bar."),
|
||||
BAS_MITZVAH : _("Bas Mitzvah abbreviation|bas."),
|
||||
BLESS: _("Blessing abbreviation|bles."),
|
||||
BURIAL: _("Burial abbreviation|bur."),
|
||||
CAUSE_DEATH : _("Cause Of Death abbreviation|d.cau."),
|
||||
CENSUS: _("Census abbreviation|cens."),
|
||||
CHRISTEN: _("Christening abbreviation|chr."),
|
||||
CONFIRMATION: _("Confirmation abbreviation|conf."),
|
||||
CREMATION: _("Cremation abbreviation|crem."),
|
||||
DEGREE: _("Degree abbreviation|deg."),
|
||||
EDUCATION: _("Education abbreviation|edu."),
|
||||
ELECTED: _("Elected abbreviation|elec."),
|
||||
EMIGRATION: _("Emigration abbreviation|em."),
|
||||
FIRST_COMMUN: _("First Communion abbreviation|f.comm."),
|
||||
IMMIGRATION: _("Immigration abbreviation|im."),
|
||||
GRADUATION: _("Graduation abbreviation|grad."),
|
||||
MED_INFO: _("Medical Information abbreviation|medinf."),
|
||||
MILITARY_SERV: _("Military Service abbreviation|milser."),
|
||||
NATURALIZATION: _("Naturalization abbreviation|nat."),
|
||||
NOB_TITLE: _("Nobility Title abbreviation|nob."),
|
||||
NUM_MARRIAGES: _("Number of Marriages abbreviation|n.o.mar."),
|
||||
OCCUPATION: _("Occupation abbreviation|occ."),
|
||||
ORDINATION: _("Ordination abbreviation|ord."),
|
||||
PROBATE: _("Probate abbreviation|prob."),
|
||||
PROPERTY: _("Property abbreviation|prop."),
|
||||
RELIGION: _("Religion abbreviation|rel."),
|
||||
RESIDENCE: _("Residence abbreviation|res."),
|
||||
RETIREMENT: _("Retirement abbreviation|ret."),
|
||||
WILL: _("Will abbreviation|will."),
|
||||
MARR_SETTL: _("Marriage Settlement abbreviation|m.set."),
|
||||
MARR_LIC: _("Marriage License abbreviation|m.lic."),
|
||||
MARR_CONTR: _("Marriage Contract abbreviation|m.con."),
|
||||
MARR_BANNS: _("Marriage Banns abbreviation|m.ban."),
|
||||
MARR_ALT: _("Alternate Marriage abbreviation|alt.mar."),
|
||||
ENGAGEMENT: _("Engagement abbreviation|engd."),
|
||||
DIVORCE: _("Divorce abbreviation|div."),
|
||||
DIV_FILING: _("Divorce Filing abbreviation|div.f."),
|
||||
ANNULMENT: _("Annulment abbreviation|annul.")
|
||||
BIRTH: _T_("birth abbreviation|b."),
|
||||
DEATH: _T_("death abbreviation|d."),
|
||||
MARRIAGE: _T_("marriage abbreviation|m."),
|
||||
UNKNOWN: _T_("Unknown abbreviation|unkn."),
|
||||
CUSTOM: _T_("Custom abbreviation|cust."),
|
||||
ADOPT: _T_("Adopted abbreviation|adop."),
|
||||
ADULT_CHRISTEN : _T_("Adult Christening abbreviation|a.chr."),
|
||||
BAPTISM: _T_("Baptism abbreviation|bap."),
|
||||
BAR_MITZVAH : _T_("Bar Mitzvah abbreviation|bar."),
|
||||
BAS_MITZVAH : _T_("Bas Mitzvah abbreviation|bas."),
|
||||
BLESS: _T_("Blessing abbreviation|bles."),
|
||||
BURIAL: _T_("Burial abbreviation|bur."),
|
||||
CAUSE_DEATH : _T_("Cause Of Death abbreviation|d.cau."),
|
||||
CENSUS: _T_("Census abbreviation|cens."),
|
||||
CHRISTEN: _T_("Christening abbreviation|chr."),
|
||||
CONFIRMATION: _T_("Confirmation abbreviation|conf."),
|
||||
CREMATION: _T_("Cremation abbreviation|crem."),
|
||||
DEGREE: _T_("Degree abbreviation|deg."),
|
||||
EDUCATION: _T_("Education abbreviation|edu."),
|
||||
ELECTED: _T_("Elected abbreviation|elec."),
|
||||
EMIGRATION: _T_("Emigration abbreviation|em."),
|
||||
FIRST_COMMUN: _T_("First Communion abbreviation|f.comm."),
|
||||
IMMIGRATION: _T_("Immigration abbreviation|im."),
|
||||
GRADUATION: _T_("Graduation abbreviation|grad."),
|
||||
MED_INFO: _T_("Medical Information abbreviation|medinf."),
|
||||
MILITARY_SERV: _T_("Military Service abbreviation|milser."),
|
||||
NATURALIZATION: _T_("Naturalization abbreviation|nat."),
|
||||
NOB_TITLE: _T_("Nobility Title abbreviation|nob."),
|
||||
NUM_MARRIAGES: _T_("Number of Marriages abbreviation|n.o.mar."),
|
||||
OCCUPATION: _T_("Occupation abbreviation|occ."),
|
||||
ORDINATION: _T_("Ordination abbreviation|ord."),
|
||||
PROBATE: _T_("Probate abbreviation|prob."),
|
||||
PROPERTY: _T_("Property abbreviation|prop."),
|
||||
RELIGION: _T_("Religion abbreviation|rel."),
|
||||
RESIDENCE: _T_("Residence abbreviation|res."),
|
||||
RETIREMENT: _T_("Retirement abbreviation|ret."),
|
||||
WILL: _T_("Will abbreviation|will."),
|
||||
MARR_SETTL: _T_("Marriage Settlement abbreviation|m.set."),
|
||||
MARR_LIC: _T_("Marriage License abbreviation|m.lic."),
|
||||
MARR_CONTR: _T_("Marriage Contract abbreviation|m.con."),
|
||||
MARR_BANNS: _T_("Marriage Banns abbreviation|m.ban."),
|
||||
MARR_ALT: _T_("Alternate Marriage abbreviation|alt.mar."),
|
||||
ENGAGEMENT: _T_("Engagement abbreviation|engd."),
|
||||
DIVORCE: _T_("Divorce abbreviation|div."),
|
||||
DIV_FILING: _T_("Divorce Filing abbreviation|div.f."),
|
||||
ANNULMENT: _T_("Annulment abbreviation|annul.")
|
||||
}
|
||||
|
||||
def __init__(self, value=None):
|
||||
@ -329,15 +333,18 @@ class EventType(GrampsType):
|
||||
return self.value == event_type[0][0] # first one, the code
|
||||
return False
|
||||
|
||||
def get_abbreviation(self):
|
||||
def get_abbreviation(self, trans_text=glocale.translation.sgettext):
|
||||
"""
|
||||
Returns the abbreviation for this event. Uses the explicitly
|
||||
given abbreviations, or first letter of each word, or the first
|
||||
three letters. Appends a period after the abbreviation,
|
||||
but not if string is in _ABBREVIATIONS.
|
||||
|
||||
If trans_text is passed in (a glocale.translation.sgettext)
|
||||
then the translated abbreviation will be returned instead.
|
||||
"""
|
||||
if self.value in self._ABBREVIATIONS:
|
||||
return self._ABBREVIATIONS[self.value]
|
||||
return trans_text(self._ABBREVIATIONS[self.value])
|
||||
else:
|
||||
abbrev = cuni(self)
|
||||
if " " in abbrev:
|
||||
|
@ -7,6 +7,7 @@
|
||||
# Copyright (C) 2010 Craig J. Anderson
|
||||
# Copyright (C) 2010 Jakim Friant
|
||||
# Copyright (C) 2011 Matt Keenan (matt.keenan@gmail.com)
|
||||
# Copyright (C) 2013 Paul Franklin
|
||||
#
|
||||
# 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
|
||||
@ -35,16 +36,17 @@ Reports/Text Reports/Descendant Report.
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import copy
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||
FONT_SANS_SERIF, INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
|
||||
FONT_SANS_SERIF, INDEX_TYPE_TOC,
|
||||
PARA_ALIGN_CENTER)
|
||||
from gramps.gen.plug.menu import (NumberOption, PersonOption, BooleanOption,
|
||||
EnumeratedListOption)
|
||||
from gramps.gen.display.name import displayer as global_name_display
|
||||
@ -53,12 +55,10 @@ from gramps.gen.plug.report import Report
|
||||
from gramps.gen.plug.report import utils as ReportUtils
|
||||
from gramps.gen.plug.report import MenuReportOptions
|
||||
from gramps.gen.plug.report import stdoptions
|
||||
from gramps.gen.datehandler import get_date
|
||||
from gramps.gen.sort import Sort
|
||||
from gramps.gen.utils.db import (get_birth_or_fallback, get_death_or_fallback,
|
||||
get_marriage_or_fallback, get_divorce_or_fallback)
|
||||
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# PrintSimple
|
||||
@ -147,7 +147,7 @@ class Printinfo():
|
||||
This class must first be initialized with set_class_vars
|
||||
"""
|
||||
def __init__(self, doc, database, numbering, showmarriage, showdivorce,\
|
||||
name_display):
|
||||
name_display, locale):
|
||||
#classes
|
||||
self._name_display = name_display
|
||||
self.doc = doc
|
||||
@ -156,22 +156,24 @@ class Printinfo():
|
||||
#variables
|
||||
self.showmarriage = showmarriage
|
||||
self.showdivorce = showdivorce
|
||||
self._ = locale.translation.sgettext # needed for English
|
||||
self._get_date = locale.get_date
|
||||
|
||||
def __date_place(self,event):
|
||||
if event:
|
||||
date = get_date(event)
|
||||
date = self._get_date(event.get_date_object())
|
||||
place_handle = event.get_place_handle()
|
||||
if place_handle:
|
||||
place = self.database.get_place_from_handle(
|
||||
place_handle).get_title()
|
||||
return("%(event_abbrev)s %(date)s - %(place)s" % {
|
||||
'event_abbrev': event.type.get_abbreviation(),
|
||||
'event_abbrev': event.type.get_abbreviation(self._),
|
||||
'date' : date,
|
||||
'place' : place,
|
||||
})
|
||||
else:
|
||||
return("%(event_abbrev)s %(date)s" % {
|
||||
'event_abbrev': event.type.get_abbreviation(),
|
||||
'event_abbrev': event.type.get_abbreviation(self._),
|
||||
'date' : date
|
||||
})
|
||||
return ""
|
||||
@ -219,12 +221,14 @@ class Printinfo():
|
||||
mark = ReportUtils.get_person_mark(self.database, spouse)
|
||||
self.doc.start_paragraph("DR-Spouse%d" % min(level, 32))
|
||||
name = self._name_display.display(spouse)
|
||||
self.doc.write_text(_("sp. %(spouse)s") % {'spouse':name}, mark)
|
||||
self.doc.write_text(
|
||||
self._("sp. %(spouse)s") % {'spouse':name}, mark)
|
||||
self.dump_string(spouse, family_handle)
|
||||
self.doc.end_paragraph()
|
||||
else:
|
||||
self.doc.start_paragraph("DR-Spouse%d" % min(level, 32))
|
||||
self.doc.write_text(_("sp. %(spouse)s") % {'spouse':'Unknown'})
|
||||
self.doc.write_text(
|
||||
self._("sp. %(spouse)s") % {'spouse':'Unknown'})
|
||||
self.doc.end_paragraph()
|
||||
|
||||
def print_reference(self, level, person, display_num):
|
||||
@ -234,7 +238,8 @@ class Printinfo():
|
||||
mark = ReportUtils.get_person_mark(self.database, person)
|
||||
self.doc.start_paragraph("DR-Spouse%d" % min(level, 32))
|
||||
name = self._name_display.display(person)
|
||||
self.doc.write_text(_("sp. see %(reference)s : %(spouse)s") %
|
||||
self.doc.write_text(
|
||||
self._("sp. see %(reference)s : %(spouse)s") %
|
||||
{'reference':display_num, 'spouse':name}, mark)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
@ -255,12 +260,13 @@ class RecurseDown():
|
||||
objPrint: A Printinfo derived class that prints person
|
||||
information on the report
|
||||
"""
|
||||
def __init__(self, max_generations, database, objPrint, showdups):
|
||||
def __init__(self, max_generations, database, objPrint, showdups, locale):
|
||||
self.max_generations = max_generations
|
||||
self.database = database
|
||||
self.objPrint = objPrint
|
||||
self.showdups = showdups
|
||||
self.person_printed = {}
|
||||
self._ = locale.translation.sgettext # needed for English
|
||||
|
||||
def recurse(self, level, person, curdepth):
|
||||
|
||||
@ -289,7 +295,7 @@ class RecurseDown():
|
||||
self.objPrint.print_spouse(level, spouse_handle, family)
|
||||
|
||||
if spouse_handle:
|
||||
spouse_num = _("%s sp." % (ref_str))
|
||||
spouse_num = self._("%s sp." % (ref_str))
|
||||
self.person_printed[spouse_handle] = spouse_num
|
||||
|
||||
if level >= self.max_generations:
|
||||
@ -337,6 +343,9 @@ class DescendantReport(Report):
|
||||
|
||||
sort = Sort(self.database)
|
||||
|
||||
lang = menu.get_option_by_name('trans').get_value()
|
||||
self._locale = self.set_locale(lang)
|
||||
|
||||
#Initialize the Printinfo class
|
||||
self._showdups = menu.get_option_by_name('dups').get_value()
|
||||
numbering = menu.get_option_by_name('numbering').get_value()
|
||||
@ -359,19 +368,19 @@ class DescendantReport(Report):
|
||||
self._name_display.set_default_format(name_format)
|
||||
|
||||
self.objPrint = Printinfo(self.doc, database, obj, marrs, divs,
|
||||
self._name_display)
|
||||
self._name_display, self._locale)
|
||||
|
||||
def write_report(self):
|
||||
self.doc.start_paragraph("DR-Title")
|
||||
name = self._name_display.display(self.center_person)
|
||||
# feature request 2356: avoid genitive form
|
||||
title = _("Descendants of %s") % name
|
||||
title = self._("Descendants of %s") % name
|
||||
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
|
||||
self.doc.write_text(title, mark)
|
||||
self.doc.end_paragraph()
|
||||
|
||||
recurse = RecurseDown(self.max_generations, self.database,
|
||||
self.objPrint, self._showdups)
|
||||
self.objPrint, self._showdups, self._locale)
|
||||
recurse.recurse(1, self.center_person, None)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
@ -421,6 +430,8 @@ class DescendantOptions(MenuReportOptions):
|
||||
dups.set_help(_("Whether to show duplicate Family Trees in the report."))
|
||||
menu.add_option(category_name, "dups", dups)
|
||||
|
||||
stdoptions.add_localization_option(menu, category_name)
|
||||
|
||||
def make_default_style(self, default_style):
|
||||
"""Make the default output style for the Descendant Report."""
|
||||
f = FontStyle()
|
||||
|
Loading…
Reference in New Issue
Block a user