add deferred translation to "living people" report option

This commit is contained in:
Paul Franklin 2016-04-15 00:29:37 -07:00
parent 67b7805de3
commit 29a5d9dbe7
38 changed files with 145 additions and 38 deletions

View File

@ -45,6 +45,10 @@ from .utils.configmanager import ConfigManager
from .const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
# _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
return value
#---------------------------------------------------------------
#
# Constants
@ -311,9 +315,9 @@ register('preferences.oprefix', 'O%04d')
register('preferences.paper-metric', 0)
register('preferences.paper-preference', 'Letter')
register('preferences.pprefix', 'P%04d')
register('preferences.private-given-text', "[%s]" % _("Living"))
register('preferences.private-given-text', "%s" % _T_("[Living]"))
register('preferences.private-record-text', "[%s]" % _("Private Record"))
register('preferences.private-surname-text', "[%s]" % _("Living"))
register('preferences.private-surname-text', "%s" % _T_("[Living]"))
register('preferences.rprefix', 'R%04d')
register('preferences.sprefix', 'S%04d')
register('preferences.use-last-view', False)

View File

@ -179,13 +179,20 @@ def add_living_people_option(menu, category,
menu.add_option(category, "years_past_death", years_past_death)
living_people_changed()
def run_living_people_option(report, menu):
def run_living_people_option(report, menu, llocale=glocale):
"""
Run the option for deciding how the information in the
database for living people shall be handled by the report
If llocale is passed in (a :class:`.GrampsLocale`), then (insofar as
possible) the translated values will be returned instead.
:param llocale: allow deferred translation of "[Living]"
:type llocale: a :class:`.GrampsLocale` instance
"""
living_people = menu.get_option_by_name('living_people').get_value()
years_past_death = menu.get_option_by_name('years_past_death').get_value()
if living_people != LivingProxyDb.MODE_INCLUDE_ALL:
report.database = LivingProxyDb(report.database, living_people,
years_after_death=years_past_death)
years_after_death=years_past_death,
llocale=llocale)

View File

@ -34,6 +34,7 @@ from ..lib import (Date, Person, Name, Surname, NameOriginType, Family, Source,
from ..utils.alive import probably_alive
from ..config import config
from gramps.gen.db.base import sort_objects
from gramps.gen.const import GRAMPS_LOCALE as glocale
#-------------------------------------------------------------------------
#
@ -51,7 +52,8 @@ class LivingProxyDb(ProxyDbBase):
MODE_REPLACE_COMPLETE_NAME = 3
MODE_INCLUDE_ALL = 99 # usually this will be only tested for, not invoked
def __init__(self, dbase, mode, current_year=None, years_after_death=0):
def __init__(self, dbase, mode,
current_year=None, years_after_death=0, llocale=glocale):
"""
Create a new LivingProxyDb instance.
@ -77,6 +79,10 @@ class LivingProxyDb(ProxyDbBase):
:param years_after_death: The number of years after a person's death to
still consider them living.
:type years_after_death: int
If llocale is passed in (a :class:`.GrampsLocale`), then (insofar as
possible) the translated values will be returned instead.
:param llocale: allow deferred translation of "[Living]"
:type llocale: a :class:`.GrampsLocale` instance
"""
ProxyDbBase.__init__(self, dbase)
self.mode = mode
@ -86,6 +92,10 @@ class LivingProxyDb(ProxyDbBase):
else:
self.current_date = None
self.years_after_death = years_after_death
self._ = llocale.translation.gettext
self._p_f_n = self._(config.get('preferences.private-given-text'))
self._p_s_n = self._(config.get('preferences.private-surname-text'))
self.__tables = {
'Person':
{
@ -400,8 +410,7 @@ class LivingProxyDb(ProxyDbBase):
new_name.set_type(old_name.get_type())
if (self.mode == self.MODE_INCLUDE_LAST_NAME_ONLY or
self.mode == self.MODE_REPLACE_COMPLETE_NAME):
new_name.set_first_name(
config.get('preferences.private-given-text'))
new_name.set_first_name(self._p_f_n)
new_name.set_title("")
else: # self.mode == self.MODE_INCLUDE_FULL_NAME_ONLY
new_name.set_first_name(old_name.get_first_name())
@ -411,16 +420,14 @@ class LivingProxyDb(ProxyDbBase):
surnlst = []
if self.mode == self.MODE_REPLACE_COMPLETE_NAME:
surname = Surname(source=old_name.get_primary_surname())
surname.set_surname(
config.get('preferences.private-surname-text'))
surname.set_surname(self._p_s_n)
surnlst.append(surname)
else:
for surn in old_name.get_surname_list():
surname = Surname(source=surn)
if int(surname.origintype) in [NameOriginType.PATRONYMIC,
NameOriginType.MATRONYMIC]:
surname.set_surname(
config.get('preferences.private-surname-text'))
surname.set_surname(self._p_s_n)
surnlst.append(surname)
new_name.set_surname_list(surnlst)

View File

@ -341,7 +341,7 @@ class ConfigureDialog(ManagedWindow):
grid.attach(hbox, 2, index, 1, 1)
def add_entry(self, grid, label, index, constant, callback=None,
config=None, col_attach=0):
config=None, col_attach=0, localized_config=True):
if not config:
config = self.__config
if not callback:
@ -349,7 +349,10 @@ class ConfigureDialog(ManagedWindow):
if label:
lwidget = BasicLabel("%s: " % label)
entry = Gtk.Entry()
entry.set_text(config.get(constant))
if localized_config:
entry.set_text(config.get(constant))
else: # it needs localizing
entry.set_text(_(config.get(constant)))
entry.connect('changed', callback, constant)
entry.set_hexpand(True)
if label:
@ -1155,10 +1158,12 @@ class GrampsPreferences(ConfigureDialog):
'preferences.no-record-text')
row += 1
self.add_entry(grid, _('Private surname'), row,
'preferences.private-surname-text')
'preferences.private-surname-text',
localized_config=False)
row += 1
self.add_entry(grid, _('Private given name'), row,
'preferences.private-given-text')
'preferences.private-given-text',
localized_config=False)
row += 1
self.add_entry(grid, _('Private record'), row,
'preferences.private-record-text')

View File

@ -1282,11 +1282,10 @@ class DescendTree(Report):
self.options = options
stdoptions.run_private_data_option(self, options.menu)
stdoptions.run_living_people_option(self, options.menu)
lang = options.menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
stdoptions.run_private_data_option(self, options.menu)
stdoptions.run_living_people_option(self, options.menu, self._locale)
stdoptions.run_name_format_option(self, options.menu)
self._nd = self._name_display

View File

@ -101,15 +101,15 @@ class TimeLine(Report):
self._user = user
menu = options.menu
lang = options.menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self._ = self._locale.translation.sgettext
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
self.filter = menu.get_option_by_name('filter').get_filter()
self._lang = options.menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(self._lang)
self._ = self._locale.translation.sgettext
stdoptions.run_name_format_option(self, menu)
sort_func_num = menu.get_option_by_name('sortby').get_value()

View File

@ -336,8 +336,11 @@ class DescendantReport(Report):
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
self.max_generations = menu.get_option_by_name('gen').get_value()
pid = menu.get_option_by_name('pid').get_value()
@ -347,9 +350,6 @@ 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()

View File

@ -132,8 +132,10 @@ class DetDescendantReport(Report):
get_option_by_name = menu.get_option_by_name
get_value = lambda name: get_option_by_name(name).get_value()
self._locale = self.set_locale(get_value('trans'))
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
self.db = self.database
self.max_generations = get_value('gen')
@ -183,8 +185,6 @@ class DetDescendantReport(Report):
else:
empty_place = ""
self._locale = self.set_locale(get_value('trans'))
stdoptions.run_name_format_option(self, menu)
self.__narrator = Narrator(self.db, self.verbose,

View File

@ -83,8 +83,12 @@ class FamilyGroup(Report):
self._user = user
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self._ = self._locale.translation.sgettext # needed for English
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
self.db = self.database
self.filter = menu.get_option_by_name('filter').get_filter()
@ -105,9 +109,6 @@ class FamilyGroup(Report):
self.incChiMar = get_value('incChiMar')
self.includeAttrs = get_value('incattrs')
self._locale = self.set_locale(get_value('trans'))
self._ = self._locale.translation.sgettext # needed for English
stdoptions.run_name_format_option(self, menu)
def dump_parent_event(self, name, event):

View File

@ -118,8 +118,11 @@ class IndivCompleteReport(Report):
self._user = user
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
self._db = self.database
self.use_pagebreak = menu.get_option_by_name('pageben').get_value()
@ -137,9 +140,6 @@ class IndivCompleteReport(Report):
self.section_list = menu.get_option_by_name('sections').get_selected()
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
stdoptions.run_name_format_option(self, menu)
def write_fact(self, event_ref, event, show_type=True):

View File

@ -1782,6 +1782,9 @@ msgid "Missing Surname"
msgstr "Falta el Cognom"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Viu]"
msgid "Living"
msgstr "Viu"

View File

@ -1810,6 +1810,9 @@ msgid "Missing Surname"
msgstr "Chybí příjmení"
#: ../gramps/gen/config.py:314 ../gramps/gen/config.py:316
msgid "[Living]"
msgstr "[Žijící]"
msgid "Living"
msgstr "Žijící"

View File

@ -1797,6 +1797,9 @@ msgid "Missing Surname"
msgstr "Manglende efternavn"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Nulevende]"
msgid "Living"
msgstr "Nulevende"

View File

@ -1835,6 +1835,9 @@ msgid "Missing Surname"
msgstr "Fehlender Nachname"
#: ../gramps/gen/config.py:314 ../gramps/gen/config.py:316
msgid "[Living]"
msgstr "[Lebt]"
msgid "Living"
msgstr "Lebt"

View File

@ -1752,6 +1752,9 @@ msgid "Missing Surname"
msgstr "Mankas Familinomo"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Vivanta]"
msgid "Living"
msgstr "Vivanta"

View File

@ -1780,6 +1780,9 @@ msgid "Missing Surname"
msgstr "Falta el apellido"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Con vida]"
msgid "Living"
msgstr "Con vida"

View File

@ -1781,6 +1781,9 @@ msgid "Missing Surname"
msgstr "Sukunimi puuttuu"
#: ../gramps/gen/config.py:314 ../gramps/gen/config.py:316
msgid "[Living]"
msgstr "[Elossa]"
msgid "Living"
msgstr "Elossa"

View File

@ -1221,6 +1221,9 @@ msgstr "Nom de famille manquant"
#: ../gramps/gen/config.py:310
#: ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Vivant]"
msgid "Living"
msgstr "Vivant"

View File

@ -1663,6 +1663,9 @@ msgid "Missing Surname"
msgstr "Nedostajuće prezime"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Živuči]"
msgid "Living"
msgstr "Živuči"

View File

@ -1805,6 +1805,9 @@ msgid "Missing Surname"
msgstr "Hiányzó vezetéknév"
#: ../gramps/gen/config.py:314 ../gramps/gen/config.py:316
msgid "[Living]"
msgstr "[Élő]"
msgid "Living"
msgstr "Élő"

View File

@ -1717,6 +1717,9 @@ msgid "Missing Surname"
msgstr "Vantar kenninafn"
#: ../gramps/gen/config.py:314 ../gramps/gen/config.py:316
msgid "[Living]"
msgstr "[Lifandi]"
msgid "Living"
msgstr "Lifandi"

View File

@ -1769,6 +1769,9 @@ msgid "Missing Surname"
msgstr "Cognome mancante"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[In vita]"
msgid "Living"
msgstr "In vita"

View File

@ -1751,6 +1751,9 @@ msgid "Missing Surname"
msgstr "Trūksta pavardės"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Gyvena]"
msgid "Living"
msgstr "Gyvena"

View File

@ -1746,6 +1746,9 @@ msgid "Missing Surname"
msgstr "Mangler etternavn"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Levende]"
msgid "Living"
msgstr "Levende"

View File

@ -1545,6 +1545,9 @@ msgid "Missing Surname"
msgstr "Ontbrekende achternaam"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Levend]"
msgid "Living"
msgstr "Levend"

View File

@ -1756,6 +1756,9 @@ msgid "Missing Surname"
msgstr "Manglar etternamn"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Levande]"
msgid "Living"
msgstr "Levande"

View File

@ -1780,6 +1780,9 @@ msgid "Missing Surname"
msgstr "Brakujące nazwisko"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Żyjący]"
msgid "Living"
msgstr "Żyjący"

View File

@ -1800,6 +1800,9 @@ msgid "Missing Surname"
msgstr "Sobrenome faltando"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Viva]"
msgid "Living"
msgstr "Viva"

View File

@ -1792,6 +1792,9 @@ msgid "Missing Surname"
msgstr "Falta o apelido"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Vivo]"
msgid "Living"
msgstr "Vivo"

View File

@ -1792,6 +1792,9 @@ msgid "Missing Surname"
msgstr "Фамилия отсутствует"
#: ../gramps/gen/config.py:314 ../gramps/gen/config.py:316
msgid "[Living]"
msgstr "[Живой]"
msgid "Living"
msgstr "Живой"

View File

@ -1679,6 +1679,9 @@ msgid "Missing Surname"
msgstr "Priezvisko chýba"
#: ../gramps/gen/config.py:311 ../gramps/gen/config.py:313
msgid "[Living]"
msgstr "[Žijúci]"
msgid "Living"
msgstr "Žijúci"

View File

@ -1730,6 +1730,9 @@ msgid "Missing Surname"
msgstr "Brez priimka"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[Še živi]"
msgid "Living"
msgstr "Še živi"

View File

@ -1747,6 +1747,9 @@ msgid "Missing Surname"
msgstr "Недостаје презиме"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[У животу]"
msgid "Living"
msgstr "У животу"

View File

@ -1753,6 +1753,9 @@ msgid "Missing Surname"
msgstr "Saknat efternamn"
#: ../gramps/gen/config.py:311 ../gramps/gen/config.py:313
msgid "[Living]"
msgstr "[Levande]"
msgid "Living"
msgstr "Levande"

View File

@ -1753,6 +1753,9 @@ msgid "Missing Surname"
msgstr "Відсутнє прізвище"
#: ../gramps/gen/config.py:311 ../gramps/gen/config.py:313
msgid "[Living]"
msgstr "[Живий(ва)]"
msgid "Living"
msgstr "Живий(ва)"

View File

@ -1577,6 +1577,9 @@ msgid "Missing Surname"
msgstr "缺失的姓"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[健在]"
msgid "Living"
msgstr "健在"

View File

@ -1578,6 +1578,9 @@ msgid "Missing Surname"
msgstr "缺失的姓"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[健在]"
msgid "Living"
msgstr "健在"

View File

@ -1578,6 +1578,9 @@ msgid "Missing Surname"
msgstr "缺失的姓"
#: ../gramps/gen/config.py:310 ../gramps/gen/config.py:312
msgid "[Living]"
msgstr "[健在]"
msgid "Living"
msgstr "健在"