svn: r13617
This commit is contained in:
parent
3f19c3d1b3
commit
adb18efb83
@ -29,7 +29,7 @@ Narrator class for use by plugins.
|
|||||||
# Standard Python modules
|
# Standard Python modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from gettext import gettext as _
|
import gettext
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -74,6 +74,8 @@ def _get_empty_endnote_numbers(obj):
|
|||||||
"""
|
"""
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def _(message): return message
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Born strings
|
# Born strings
|
||||||
@ -1459,6 +1461,7 @@ class Narrator(object):
|
|||||||
|
|
||||||
def __init__(self, dbase, verbose=True, use_call_name=False,
|
def __init__(self, dbase, verbose=True, use_call_name=False,
|
||||||
empty_date="", empty_place="",
|
empty_date="", empty_place="",
|
||||||
|
translate_text=gettext.gettext,
|
||||||
get_endnote_numbers=_get_empty_endnote_numbers):
|
get_endnote_numbers=_get_empty_endnote_numbers):
|
||||||
"""
|
"""
|
||||||
Initialize the narrator class.
|
Initialize the narrator class.
|
||||||
@ -1474,6 +1477,9 @@ class Narrator(object):
|
|||||||
:type empty_date: str
|
:type empty_date: str
|
||||||
:param empty_place: String to use when a place is not known.
|
:param empty_place: String to use when a place is not known.
|
||||||
:type empty_place: str
|
:type empty_place: str
|
||||||
|
:param translate_text: A function that returns a translated message
|
||||||
|
string given a message id (similar to gettext).
|
||||||
|
:type translate_text: callable(str)
|
||||||
:param get_endnote_numbers: A callable to use for getting a string
|
:param get_endnote_numbers: A callable to use for getting a string
|
||||||
representing endnote numbers.
|
representing endnote numbers.
|
||||||
The function takes a :class:`~gen.lib.srcbase,SourceBase` instance.
|
The function takes a :class:`~gen.lib.srcbase,SourceBase` instance.
|
||||||
@ -1488,6 +1494,7 @@ class Narrator(object):
|
|||||||
self.__empty_date = empty_date
|
self.__empty_date = empty_date
|
||||||
self.__empty_place = empty_place
|
self.__empty_place = empty_place
|
||||||
self.__get_endnote_numbers = get_endnote_numbers
|
self.__get_endnote_numbers = get_endnote_numbers
|
||||||
|
self.__translate_text = translate_text
|
||||||
self.__person = None
|
self.__person = None
|
||||||
self.__first_name = ""
|
self.__first_name = ""
|
||||||
self.__first_name_used = False
|
self.__first_name_used = False
|
||||||
@ -1565,39 +1572,41 @@ class Narrator(object):
|
|||||||
if bdate:
|
if bdate:
|
||||||
if bdate_mod:
|
if bdate_mod:
|
||||||
if bplace and self.__verbose:
|
if bplace and self.__verbose:
|
||||||
text = born_modified_date_with_place[name_index][gender] % value_map
|
text = born_modified_date_with_place[name_index][gender]
|
||||||
elif bplace:
|
elif bplace:
|
||||||
text = born_modified_date_with_place[2] % value_map
|
text = born_modified_date_with_place[2]
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
text = born_modified_date_no_place[name_index][gender] % value_map
|
text = born_modified_date_no_place[name_index][gender]
|
||||||
else:
|
else:
|
||||||
text = born_modified_date_no_place[2] % value_map
|
text = born_modified_date_no_place[2]
|
||||||
elif bdate_full:
|
elif bdate_full:
|
||||||
if bplace and self.__verbose:
|
if bplace and self.__verbose:
|
||||||
text = born_full_date_with_place[name_index][gender] % value_map
|
text = born_full_date_with_place[name_index][gender]
|
||||||
elif bplace:
|
elif bplace:
|
||||||
text = born_full_date_with_place[2] % value_map
|
text = born_full_date_with_place[2]
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
text = born_full_date_no_place[name_index][gender] % value_map
|
text = born_full_date_no_place[name_index][gender]
|
||||||
else:
|
else:
|
||||||
text = born_full_date_no_place[2] % value_map
|
text = born_full_date_no_place[2]
|
||||||
else:
|
else:
|
||||||
if bplace and self.__verbose:
|
if bplace and self.__verbose:
|
||||||
text = born_partial_date_with_place[name_index][gender] % value_map
|
text = born_partial_date_with_place[name_index][gender]
|
||||||
elif bplace:
|
elif bplace:
|
||||||
text = born_partial_date_with_place[2] % value_map
|
text = born_partial_date_with_place[2]
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
text = born_partial_date_no_place[name_index][gender] % value_map
|
text = born_partial_date_no_place[name_index][gender]
|
||||||
else:
|
else:
|
||||||
text = born_partial_date_no_place[2] % value_map
|
text = born_partial_date_no_place[2]
|
||||||
else:
|
else:
|
||||||
if bplace and self.__verbose:
|
if bplace and self.__verbose:
|
||||||
text = born_no_date_with_place[name_index][gender] % value_map
|
text = born_no_date_with_place[name_index][gender]
|
||||||
elif bplace:
|
elif bplace:
|
||||||
text = born_no_date_with_place[2] % value_map
|
text = born_no_date_with_place[2]
|
||||||
else:
|
else:
|
||||||
text = ""
|
text = ""
|
||||||
|
|
||||||
|
text = self.__translate_text(text) % value_map
|
||||||
|
|
||||||
if text and birth_event:
|
if text and birth_event:
|
||||||
text = text.rstrip(". ")
|
text = text.rstrip(". ")
|
||||||
text = text + self.__get_endnote_numbers(birth_event) + ". "
|
text = text + self.__get_endnote_numbers(birth_event) + ". "
|
||||||
@ -1677,43 +1686,43 @@ class Narrator(object):
|
|||||||
|
|
||||||
gender = self.__person.get_gender()
|
gender = self.__person.get_gender()
|
||||||
|
|
||||||
if ddate:
|
if ddate and ddate_mod:
|
||||||
if ddate_mod:
|
|
||||||
if dplace and self.__verbose:
|
if dplace and self.__verbose:
|
||||||
text = died_modified_date_with_place[name_index][gender][age_index] % value_map
|
text = died_modified_date_with_place[name_index][gender][age_index]
|
||||||
elif dplace:
|
elif dplace:
|
||||||
text = died_modified_date_with_place[2][age_index] % value_map
|
text = died_modified_date_with_place[2][age_index]
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
text = died_modified_date_no_place[name_index][gender][age_index] % value_map
|
text = died_modified_date_no_place[name_index][gender][age_index]
|
||||||
else:
|
else:
|
||||||
text = died_modified_date_no_place[2][age_index] % value_map
|
text = died_modified_date_no_place[2][age_index]
|
||||||
elif ddate_full:
|
elif ddate and ddate_full:
|
||||||
if dplace and self.__verbose:
|
if dplace and self.__verbose:
|
||||||
text = died_full_date_with_place[name_index][gender][age_index] % value_map
|
text = died_full_date_with_place[name_index][gender][age_index]
|
||||||
elif dplace:
|
elif dplace:
|
||||||
text = died_full_date_with_place[2][age_index] % value_map
|
text = died_full_date_with_place[2][age_index]
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
text = died_full_date_no_place[name_index][gender][age_index] % value_map
|
text = died_full_date_no_place[name_index][gender][age_index]
|
||||||
else:
|
|
||||||
text = died_full_date_no_place[2][age_index] % value_map
|
|
||||||
else:
|
else:
|
||||||
|
text = died_full_date_no_place[2][age_index]
|
||||||
|
elif ddate:
|
||||||
if dplace and self.__verbose:
|
if dplace and self.__verbose:
|
||||||
text = died_partial_date_with_place[name_index][gender][age_index] % value_map
|
text = died_partial_date_with_place[name_index][gender][age_index]
|
||||||
elif dplace:
|
elif dplace:
|
||||||
text = died_partial_date_with_place[2][age_index] % value_map
|
text = died_partial_date_with_place[2][age_index]
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
text = died_partial_date_no_place[name_index][gender][age_index] % value_map
|
text = died_partial_date_no_place[name_index][gender][age_index]
|
||||||
else:
|
else:
|
||||||
text = died_partial_date_no_place[2][age_index] % value_map
|
text = died_partial_date_no_place[2][age_index]
|
||||||
else:
|
elif dplace and self.__verbose:
|
||||||
if dplace and self.__verbose:
|
text = died_no_date_with_place[name_index][gender][age_index]
|
||||||
text = died_no_date_with_place[name_index][gender][age_index] % value_map
|
|
||||||
elif dplace:
|
elif dplace:
|
||||||
text = died_no_date_with_place[2][age_index] % value_map
|
text = died_no_date_with_place[2][age_index]
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
text = died_no_date_no_place[name_index][gender][age_index] % value_map
|
text = died_no_date_no_place[name_index][gender][age_index]
|
||||||
else:
|
else:
|
||||||
text = died_no_date_no_place[2][age_index] % value_map
|
text = died_no_date_no_place[2][age_index]
|
||||||
|
|
||||||
|
text = self.__translate_text(text) % value_map
|
||||||
|
|
||||||
if text and death_event:
|
if text and death_event:
|
||||||
text = text.rstrip(". ")
|
text = text.rstrip(". ")
|
||||||
@ -1773,7 +1782,7 @@ class Narrator(object):
|
|||||||
else:
|
else:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
values = {
|
value_map = {
|
||||||
'unknown_gender_name' : self.__first_name,
|
'unknown_gender_name' : self.__first_name,
|
||||||
'male_name' : self.__first_name,
|
'male_name' : self.__first_name,
|
||||||
'name' : self.__first_name,
|
'name' : self.__first_name,
|
||||||
@ -1787,42 +1796,44 @@ class Narrator(object):
|
|||||||
|
|
||||||
if bdate and bdate_mod and self.__verbose:
|
if bdate and bdate_mod and self.__verbose:
|
||||||
if bplace: #male, date, place
|
if bplace: #male, date, place
|
||||||
text = buried_modified_date_place[gender][name_index] % values
|
text = buried_modified_date_place[gender][name_index]
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = buried_modified_date_no_place[gender][name_index] % values
|
text = buried_modified_date_no_place[gender][name_index]
|
||||||
elif bdate and bdate_mod:
|
elif bdate and bdate_mod:
|
||||||
if bplace: #male, date, place
|
if bplace: #male, date, place
|
||||||
text = buried_modified_date_place['succinct'] % values
|
text = buried_modified_date_place['succinct']
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = buried_modified_date_no_place['succinct'] % values
|
text = buried_modified_date_no_place['succinct']
|
||||||
elif bdate and bdate_full and self.__verbose:
|
elif bdate and bdate_full and self.__verbose:
|
||||||
if bplace: #male, date, place
|
if bplace: #male, date, place
|
||||||
text = buried_full_date_place[gender][name_index] % values
|
text = buried_full_date_place[gender][name_index]
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = buried_full_date_no_place[gender][name_index] % values
|
text = buried_full_date_no_place[gender][name_index]
|
||||||
elif bdate and bdate_full:
|
elif bdate and bdate_full:
|
||||||
if bplace: #male, date, place
|
if bplace: #male, date, place
|
||||||
text = buried_full_date_place['succinct'] % values
|
text = buried_full_date_place['succinct']
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = buried_full_date_no_place['succinct'] % values
|
text = buried_full_date_no_place['succinct']
|
||||||
elif bdate and self.__verbose:
|
elif bdate and self.__verbose:
|
||||||
if bplace: #male, month_year, place
|
if bplace: #male, month_year, place
|
||||||
text = buried_partial_date_place[gender][name_index] % values
|
text = buried_partial_date_place[gender][name_index]
|
||||||
else: #male, month_year, no place
|
else: #male, month_year, no place
|
||||||
text = buried_partial_date_no_place[gender][name_index] % values
|
text = buried_partial_date_no_place[gender][name_index]
|
||||||
elif bdate:
|
elif bdate:
|
||||||
if bplace: #male, month_year, place
|
if bplace: #male, month_year, place
|
||||||
text = buried_partial_date_place['succinct'] % values
|
text = buried_partial_date_place['succinct']
|
||||||
else: #male, month_year, no place
|
else: #male, month_year, no place
|
||||||
text = buried_partial_date_no_place['succinct'] % values
|
text = buried_partial_date_no_place['succinct']
|
||||||
elif bplace and self.__verbose: #male, no date, place
|
elif bplace and self.__verbose: #male, no date, place
|
||||||
text = buried_no_date_place[gender][name_index] % values
|
text = buried_no_date_place[gender][name_index]
|
||||||
elif bplace: #male, no date, place
|
elif bplace: #male, no date, place
|
||||||
text = buried_no_date_place['succinct'] % values
|
text = buried_no_date_place['succinct']
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
text = buried_no_date_no_place[gender][name_index] % values
|
text = buried_no_date_no_place[gender][name_index]
|
||||||
else: #male, no date, no place
|
else: #male, no date, no place
|
||||||
text = buried_no_date_no_place['succinct'] % values
|
text = buried_no_date_no_place['succinct']
|
||||||
|
|
||||||
|
text = self.__translate_text(text) % value_map
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
text = text + " "
|
text = text + " "
|
||||||
@ -1878,7 +1889,7 @@ class Narrator(object):
|
|||||||
else:
|
else:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
values = {
|
value_map = {
|
||||||
'unknown_gender_name' : self.__first_name,
|
'unknown_gender_name' : self.__first_name,
|
||||||
'male_name' : self.__first_name,
|
'male_name' : self.__first_name,
|
||||||
'name' : self.__first_name,
|
'name' : self.__first_name,
|
||||||
@ -1892,42 +1903,44 @@ class Narrator(object):
|
|||||||
|
|
||||||
if bdate and bdate_mod and self.__verbose:
|
if bdate and bdate_mod and self.__verbose:
|
||||||
if bplace: #male, date, place
|
if bplace: #male, date, place
|
||||||
text = baptised_modified_date_place[gender][name_index] % values
|
text = baptised_modified_date_place[gender][name_index]
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = baptised_modified_date_no_place[gender][name_index] % values
|
text = baptised_modified_date_no_place[gender][name_index]
|
||||||
elif bdate and bdate_mod:
|
elif bdate and bdate_mod:
|
||||||
if bplace: #male, date, place
|
if bplace: #male, date, place
|
||||||
text = baptised_modified_date_place['succinct'] % values
|
text = baptised_modified_date_place['succinct']
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = baptised_modified_date_no_place['succinct'] % values
|
text = baptised_modified_date_no_place['succinct']
|
||||||
elif bdate and bdate_full and self.__verbose:
|
elif bdate and bdate_full and self.__verbose:
|
||||||
if bplace: #male, date, place
|
if bplace: #male, date, place
|
||||||
text = baptised_full_date_place[gender][name_index] % values
|
text = baptised_full_date_place[gender][name_index]
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = baptised_full_date_no_place[gender][name_index] % values
|
text = baptised_full_date_no_place[gender][name_index]
|
||||||
elif bdate and bdate_full:
|
elif bdate and bdate_full:
|
||||||
if bplace: #male, date, place
|
if bplace: #male, date, place
|
||||||
text = baptised_full_date_place['succinct'] % values
|
text = baptised_full_date_place['succinct']
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = baptised_full_date_no_place['succinct'] % values
|
text = baptised_full_date_no_place['succinct']
|
||||||
elif bdate and self.__verbose:
|
elif bdate and self.__verbose:
|
||||||
if bplace: #male, month_year, place
|
if bplace: #male, month_year, place
|
||||||
text = baptised_partial_date_place[gender][name_index] % values
|
text = baptised_partial_date_place[gender][name_index]
|
||||||
else: #male, month_year, no place
|
else: #male, month_year, no place
|
||||||
text = baptised_partial_date_no_place[gender][name_index] % values
|
text = baptised_partial_date_no_place[gender][name_index]
|
||||||
elif bdate:
|
elif bdate:
|
||||||
if bplace: #male, month_year, place
|
if bplace: #male, month_year, place
|
||||||
text = baptised_partial_date_place['succinct'] % values
|
text = baptised_partial_date_place['succinct']
|
||||||
else: #male, month_year, no place
|
else: #male, month_year, no place
|
||||||
text = baptised_partial_date_no_place['succinct'] % values
|
text = baptised_partial_date_no_place['succinct']
|
||||||
elif bplace and self.__verbose: #male, no date, place
|
elif bplace and self.__verbose: #male, no date, place
|
||||||
text = baptised_no_date_place[gender][name_index] % values
|
text = baptised_no_date_place[gender][name_index]
|
||||||
elif bplace: #male, no date, place
|
elif bplace: #male, no date, place
|
||||||
text = baptised_no_date_place['succinct'] % values
|
text = baptised_no_date_place['succinct']
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
text = baptised_no_date_no_place[gender][name_index] % values
|
text = baptised_no_date_no_place[gender][name_index]
|
||||||
else: #male, no date, no place
|
else: #male, no date, no place
|
||||||
text = baptised_no_date_no_place['succinct'] % values
|
text = baptised_no_date_no_place['succinct']
|
||||||
|
|
||||||
|
text = self.__translate_text(text) % value_map
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
text = text + " "
|
text = text + " "
|
||||||
@ -1983,7 +1996,7 @@ class Narrator(object):
|
|||||||
else:
|
else:
|
||||||
return text
|
return text
|
||||||
|
|
||||||
values = {
|
value_map = {
|
||||||
'unknown_gender_name' : self.__first_name,
|
'unknown_gender_name' : self.__first_name,
|
||||||
'male_name' : self.__first_name,
|
'male_name' : self.__first_name,
|
||||||
'name' : self.__first_name,
|
'name' : self.__first_name,
|
||||||
@ -1997,42 +2010,44 @@ class Narrator(object):
|
|||||||
|
|
||||||
if cdate and cdate_mod and self.__verbose:
|
if cdate and cdate_mod and self.__verbose:
|
||||||
if cplace: #male, date, place
|
if cplace: #male, date, place
|
||||||
text = christened_modified_date_place[gender][name_index] % values
|
text = christened_modified_date_place[gender][name_index]
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = christened_modified_date_no_place[gender][name_index] % values
|
text = christened_modified_date_no_place[gender][name_index]
|
||||||
elif cdate and cdate_mod:
|
elif cdate and cdate_mod:
|
||||||
if cplace: #male, date, place
|
if cplace: #male, date, place
|
||||||
text = christened_modified_date_place['succinct'] % values
|
text = christened_modified_date_place['succinct']
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = christened_modified_date_no_place['succinct'] % values
|
text = christened_modified_date_no_place['succinct']
|
||||||
elif cdate and cdate_full and self.__verbose:
|
elif cdate and cdate_full and self.__verbose:
|
||||||
if cplace: #male, date, place
|
if cplace: #male, date, place
|
||||||
text = christened_full_date_place[gender][name_index] % values
|
text = christened_full_date_place[gender][name_index]
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = christened_full_date_no_place[gender][name_index] % values
|
text = christened_full_date_no_place[gender][name_index]
|
||||||
elif cdate and cdate_full:
|
elif cdate and cdate_full:
|
||||||
if cplace: #male, date, place
|
if cplace: #male, date, place
|
||||||
text = christened_full_date_place['succinct'] % values
|
text = christened_full_date_place['succinct']
|
||||||
else: #male, date, no place
|
else: #male, date, no place
|
||||||
text = christened_full_date_no_place['succinct'] % values
|
text = christened_full_date_no_place['succinct']
|
||||||
elif cdate and self.__verbose:
|
elif cdate and self.__verbose:
|
||||||
if cplace: #male, month_year, place
|
if cplace: #male, month_year, place
|
||||||
text = christened_partial_date_place[gender][name_index] % values
|
text = christened_partial_date_place[gender][name_index]
|
||||||
else: #male, month_year, no place
|
else: #male, month_year, no place
|
||||||
text = christened_partial_date_no_place[gender][name_index] % values
|
text = christened_partial_date_no_place[gender][name_index]
|
||||||
elif cdate:
|
elif cdate:
|
||||||
if cplace: #male, month_year, place
|
if cplace: #male, month_year, place
|
||||||
text = christened_partial_date_place['succinct'] % values
|
text = christened_partial_date_place['succinct']
|
||||||
else: #male, month_year, no place
|
else: #male, month_year, no place
|
||||||
text = christened_partial_date_no_place['succinct'] % values
|
text = christened_partial_date_no_place['succinct']
|
||||||
elif cplace and self.__verbose: #male, no date, place
|
elif cplace and self.__verbose: #male, no date, place
|
||||||
text = christened_no_date_place[gender][name_index] % values
|
text = christened_no_date_place[gender][name_index]
|
||||||
elif cplace: #male, no date, place
|
elif cplace: #male, no date, place
|
||||||
text = christened_no_date_place['succinct'] % values
|
text = christened_no_date_place['succinct']
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
text = christened_no_date_no_place[gender][name_index] % values
|
text = christened_no_date_no_place[gender][name_index]
|
||||||
else: #male, no date, no place
|
else: #male, no date, no place
|
||||||
text = christened_no_date_no_place['succinct'] % values
|
text = christened_no_date_no_place['succinct']
|
||||||
|
|
||||||
|
text = self.__translate_text(text) % value_map
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
text = text + " "
|
text = text + " "
|
||||||
@ -2080,7 +2095,7 @@ class Narrator(object):
|
|||||||
place = place_obj.get_title()
|
place = place_obj.get_title()
|
||||||
relationship = family.get_relationship()
|
relationship = family.get_relationship()
|
||||||
|
|
||||||
values = {
|
value_map = {
|
||||||
'spouse' : spouse_name,
|
'spouse' : spouse_name,
|
||||||
'endnotes' : self.__get_endnote_numbers(event),
|
'endnotes' : self.__get_endnote_numbers(event),
|
||||||
'full_date' : date,
|
'full_date' : date,
|
||||||
@ -2117,117 +2132,119 @@ class Narrator(object):
|
|||||||
if is_first:
|
if is_first:
|
||||||
if event and date and place and self.__verbose:
|
if event and date and place and self.__verbose:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_first_date_place[gender][date_full] % values
|
text = marriage_first_date_place[gender][date_full]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_first_date_place[gender][date_full] % values
|
text = unmarried_first_date_place[gender][date_full]
|
||||||
else:
|
else:
|
||||||
text = relationship_first_date_place[gender][date_full] % values
|
text = relationship_first_date_place[gender][date_full]
|
||||||
elif event and date and place:
|
elif event and date and place:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_first_date_place['succinct'][date_full] % values
|
text = marriage_first_date_place['succinct'][date_full]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_first_date_place['succinct'][date_full] % values
|
text = unmarried_first_date_place['succinct'][date_full]
|
||||||
else:
|
else:
|
||||||
text = relationship_first_date_place['succinct'][date_full] % values
|
text = relationship_first_date_place['succinct'][date_full]
|
||||||
elif event and date and self.__verbose:
|
elif event and date and self.__verbose:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_first_date[gender][date_full] % values
|
text = marriage_first_date[gender][date_full]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_first_date[gender][date_full] % values
|
text = unmarried_first_date[gender][date_full]
|
||||||
else:
|
else:
|
||||||
text = relationship_first_date[gender][date_full] % values
|
text = relationship_first_date[gender][date_full]
|
||||||
elif event and date:
|
elif event and date:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_first_date['succinct'][date_full] % values
|
text = marriage_first_date['succinct'][date_full]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_first_date['succinct'][date_full] % values
|
text = unmarried_first_date['succinct'][date_full]
|
||||||
else:
|
else:
|
||||||
text = relationship_first_date['succinct'][date_full] % values
|
text = relationship_first_date['succinct'][date_full]
|
||||||
elif event and place and self.__verbose:
|
elif event and place and self.__verbose:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_first_place[gender] % values
|
text = marriage_first_place[gender]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_first_place[gender] % values
|
text = unmarried_first_place[gender]
|
||||||
else:
|
else:
|
||||||
text = relationship_first_place[gender] % values
|
text = relationship_first_place[gender]
|
||||||
elif event and place:
|
elif event and place:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_first_place['succinct'] % values
|
text = marriage_first_place['succinct']
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_first_place['succinct'] % values
|
text = unmarried_first_place['succinct']
|
||||||
else:
|
else:
|
||||||
text = relationship_first_place['succinct'] % values
|
text = relationship_first_place['succinct']
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_first_only[gender] % values
|
text = marriage_first_only[gender]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_first_only[gender] % values
|
text = unmarried_first_only[gender]
|
||||||
else:
|
else:
|
||||||
text = relationship_first_only[gender] % values
|
text = relationship_first_only[gender]
|
||||||
else:
|
else:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_first_only['succinct'] % values
|
text = marriage_first_only['succinct']
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_first_only['succinct'] % values
|
text = unmarried_first_only['succinct']
|
||||||
else:
|
else:
|
||||||
text = relationship_first_only['succinct'] % values
|
text = relationship_first_only['succinct']
|
||||||
else:
|
else:
|
||||||
if event and date and place and self.__verbose:
|
if event and date and place and self.__verbose:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_also_date_place[gender][date_full] % values
|
text = marriage_also_date_place[gender][date_full]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_also_date_place[gender][date_full] % values
|
text = unmarried_also_date_place[gender][date_full]
|
||||||
else:
|
else:
|
||||||
text = relationship_also_date_place[gender][date_full] % values
|
text = relationship_also_date_place[gender][date_full]
|
||||||
if event and date and place:
|
if event and date and place:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_also_date_place['succinct'][date_full] % values
|
text = marriage_also_date_place['succinct'][date_full]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_also_date_place['succinct'][date_full] % values
|
text = unmarried_also_date_place['succinct'][date_full]
|
||||||
else:
|
else:
|
||||||
text = relationship_also_date_place['succinct'][date_full] % values
|
text = relationship_also_date_place['succinct'][date_full]
|
||||||
elif event and date and self.__verbose:
|
elif event and date and self.__verbose:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_also_date[gender][date_full] % values
|
text = marriage_also_date[gender][date_full]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_also_date[gender][date_full] % values
|
text = unmarried_also_date[gender][date_full]
|
||||||
else:
|
else:
|
||||||
text = relationship_also_date[gender][date_full] % values
|
text = relationship_also_date[gender][date_full]
|
||||||
elif event and date:
|
elif event and date:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_also_date['succinct'][date_full] % values
|
text = marriage_also_date['succinct'][date_full]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_also_date['succinct'][date_full] % values
|
text = unmarried_also_date['succinct'][date_full]
|
||||||
else:
|
else:
|
||||||
text = relationship_also_date['succinct'][date_full] % values
|
text = relationship_also_date['succinct'][date_full]
|
||||||
elif event and place and self.__verbose:
|
elif event and place and self.__verbose:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_also_place[gender] % values
|
text = marriage_also_place[gender]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_also_place[gender] % values
|
text = unmarried_also_place[gender]
|
||||||
else:
|
else:
|
||||||
text = relationship_also_place[gender] % values
|
text = relationship_also_place[gender]
|
||||||
elif event and place:
|
elif event and place:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_also_place['succinct'] % values
|
text = marriage_also_place['succinct']
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_also_place['succinct'] % values
|
text = unmarried_also_place['succinct']
|
||||||
else:
|
else:
|
||||||
text = relationship_also_place['succinct'] % values
|
text = relationship_also_place['succinct']
|
||||||
elif self.__verbose:
|
elif self.__verbose:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_also_only[gender] % values
|
text = marriage_also_only[gender]
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_also_only[gender] % values
|
text = unmarried_also_only[gender]
|
||||||
else:
|
else:
|
||||||
text = relationship_also_only[gender] % values
|
text = relationship_also_only[gender]
|
||||||
else:
|
else:
|
||||||
if relationship == FamilyRelType.MARRIED:
|
if relationship == FamilyRelType.MARRIED:
|
||||||
text = marriage_also_only['succinct'] % values
|
text = marriage_also_only['succinct']
|
||||||
elif relationship == FamilyRelType.UNMARRIED:
|
elif relationship == FamilyRelType.UNMARRIED:
|
||||||
text = unmarried_also_only['succinct'] % values
|
text = unmarried_also_only['succinct']
|
||||||
else:
|
else:
|
||||||
text = relationship_also_only['succinct'] % values
|
text = relationship_also_only['succinct']
|
||||||
|
|
||||||
|
text = self.__translate_text(text) % value_map
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
text = text + " "
|
text = text + " "
|
||||||
@ -2250,7 +2267,7 @@ class Narrator(object):
|
|||||||
:rtype: unicode
|
:rtype: unicode
|
||||||
"""
|
"""
|
||||||
|
|
||||||
values = {
|
value_map = {
|
||||||
'father' : father_name,
|
'father' : father_name,
|
||||||
'mother' : mother_name,
|
'mother' : mother_name,
|
||||||
'male_name' : self.__first_name,
|
'male_name' : self.__first_name,
|
||||||
@ -2271,19 +2288,23 @@ class Narrator(object):
|
|||||||
|
|
||||||
text = ""
|
text = ""
|
||||||
if mother_name and father_name and self.__verbose:
|
if mother_name and father_name and self.__verbose:
|
||||||
text = child_father_mother[gender][index][dead] % values
|
text = child_father_mother[gender][index][dead]
|
||||||
elif mother_name and father_name:
|
elif mother_name and father_name:
|
||||||
text = child_father_mother[gender][2] % values
|
text = child_father_mother[gender][2]
|
||||||
elif mother_name and self.__verbose:
|
elif mother_name and self.__verbose:
|
||||||
text = child_mother[gender][index][dead] % values
|
text = child_mother[gender][index][dead]
|
||||||
elif mother_name:
|
elif mother_name:
|
||||||
text = child_mother[gender][2] % values
|
text = child_mother[gender][2]
|
||||||
elif father_name and self.__verbose:
|
elif father_name and self.__verbose:
|
||||||
text = child_father[gender][index][dead] % values
|
text = child_father[gender][index][dead]
|
||||||
elif father_name:
|
elif father_name:
|
||||||
text = child_father[gender][2] % values
|
text = child_father[gender][2]
|
||||||
|
|
||||||
|
text = self.__translate_text(text) % value_map
|
||||||
|
|
||||||
if text:
|
if text:
|
||||||
text = text + " "
|
text = text + " "
|
||||||
|
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def __get_age_at_death(self):
|
def __get_age_at_death(self):
|
||||||
|
@ -39,7 +39,8 @@ from gettext import gettext as _
|
|||||||
from BasicUtils import name_displayer
|
from BasicUtils import name_displayer
|
||||||
from Errors import ReportError
|
from Errors import ReportError
|
||||||
from gen.lib import ChildRefType
|
from gen.lib import ChildRefType
|
||||||
from gen.plug.menu import BooleanOption, NumberOption, PersonOption
|
from gen.plug.menu import BooleanOption, NumberOption, PersonOption, \
|
||||||
|
TranslationOption
|
||||||
from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle,
|
||||||
FONT_SANS_SERIF, INDEX_TYPE_TOC,
|
FONT_SANS_SERIF, INDEX_TYPE_TOC,
|
||||||
PARA_ALIGN_CENTER)
|
PARA_ALIGN_CENTER)
|
||||||
@ -97,7 +98,10 @@ class AncestorReport(Report):
|
|||||||
self.center_person = database.get_person_from_gramps_id(pid)
|
self.center_person = database.get_person_from_gramps_id(pid)
|
||||||
if (self.center_person == None) :
|
if (self.center_person == None) :
|
||||||
raise ReportError(_("Person %s is not in the Database") % pid )
|
raise ReportError(_("Person %s is not in the Database") % pid )
|
||||||
self.__narrator = Narrator(self.database)
|
translator = menu.get_option_by_name('trans').get_translator()
|
||||||
|
self._ = translator.gettext
|
||||||
|
self.__narrator = Narrator(self.database,
|
||||||
|
translate_text = translator.gettext)
|
||||||
|
|
||||||
def apply_filter(self, person_handle, index, generation=1):
|
def apply_filter(self, person_handle, index, generation=1):
|
||||||
"""
|
"""
|
||||||
@ -169,7 +173,7 @@ class AncestorReport(Report):
|
|||||||
# 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.
|
||||||
|
|
||||||
name = name_displayer.display_formal(self.center_person)
|
name = name_displayer.display_formal(self.center_person)
|
||||||
title = _("Ahnentafel Report for %s") % name
|
title = self._("Ahnentafel Report for %s") % name
|
||||||
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
|
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
|
||||||
self.doc.start_paragraph("AHN-Title")
|
self.doc.start_paragraph("AHN-Title")
|
||||||
self.doc.write_text(title, mark)
|
self.doc.write_text(title, mark)
|
||||||
@ -192,7 +196,7 @@ class AncestorReport(Report):
|
|||||||
# Create the Generation title, set an index marker
|
# Create the Generation title, set an index marker
|
||||||
mark = IndexMark(title, INDEX_TYPE_TOC, 2)
|
mark = IndexMark(title, INDEX_TYPE_TOC, 2)
|
||||||
self.doc.start_paragraph("AHN-Generation")
|
self.doc.start_paragraph("AHN-Generation")
|
||||||
self.doc.write_text(_("Generation %d") % generation, mark)
|
self.doc.write_text(self._("Generation %d") % generation, mark)
|
||||||
self.doc.end_paragraph()
|
self.doc.end_paragraph()
|
||||||
|
|
||||||
# Build the entry
|
# Build the entry
|
||||||
@ -263,6 +267,10 @@ class AncestorOptions(MenuReportOptions):
|
|||||||
namebrk.set_help(_("Indicates if a line break should follow the name."))
|
namebrk.set_help(_("Indicates if a line break should follow the name."))
|
||||||
menu.add_option(category_name, "namebrk", namebrk)
|
menu.add_option(category_name, "namebrk", namebrk)
|
||||||
|
|
||||||
|
trans = TranslationOption(_("Translation"))
|
||||||
|
trans.set_help(_("The translation to be used for the report."))
|
||||||
|
menu.add_option(category_name, "trans", trans)
|
||||||
|
|
||||||
def make_default_style(self, default_style):
|
def make_default_style(self, default_style):
|
||||||
"""
|
"""
|
||||||
Make the default output style for the Ahnentafel report.
|
Make the default output style for the Ahnentafel report.
|
||||||
|
Loading…
Reference in New Issue
Block a user