add the date-format option to some more reports

This commit is contained in:
Paul Franklin 2017-04-14 13:54:24 -07:00
parent 38239526f6
commit 8379e0ce6e
25 changed files with 113 additions and 78 deletions

View File

@ -69,9 +69,7 @@ class Report:
stdoptions.add_localization_option().
"""
from ...datehandler import LANG_TO_DISPLAY, main_locale
if language == GrampsLocale.DEFAULT_TRANSLATION_STR:
language = None
if language is None: # the UI language
if language == GrampsLocale.DEFAULT_TRANSLATION_STR: # the UI language
locale = glocale
elif language in LANG_TO_DISPLAY: # a displayer exists
locale = LANG_TO_DISPLAY[main_locale[language]]._locale
@ -85,6 +83,7 @@ class Report:
self._name_display.set_name_format(self.database.name_formats)
fmt_default = config.get('preferences.name-format')
self._name_display.set_default_format(fmt_default)
self._locale = locale # define it here rather than in every report
return locale
def write_report(self):

View File

@ -556,8 +556,8 @@ class AncestorTree(Report):
self.options = options
self._user = user
lang = options.menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self.set_locale(options.menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, options.menu)
stdoptions.run_private_data_option(self, options.menu)
stdoptions.run_living_people_option(self, options.menu, self._locale)
self.database = CacheProxyDb(self.database)
@ -901,7 +901,9 @@ class AncestorTreeOptions(MenuReportOptions):
stdoptions.add_private_data_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
##################
category_name = _("Display")

View File

@ -112,7 +112,7 @@ class Calendar(Report):
if (self.center_person == None) :
raise ReportError(_("Person %s is not in the Database") % pid )
self._locale = self.set_locale(get_value('trans'))
self.set_locale(get_value('trans'))
def get_name(self, person, maiden_name = None):
""" Return person's name, unless maiden_name given,

View File

@ -1291,8 +1291,8 @@ class DescendTree(Report):
self.options = options
lang = options.menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self.set_locale(options.menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, options.menu)
stdoptions.run_private_data_option(self, options.menu)
stdoptions.run_living_people_option(self, options.menu, self._locale)
self.database = CacheProxyDb(self.database)
@ -1637,7 +1637,9 @@ class DescendTreeOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
##################
category_name = _("Display")

View File

@ -176,11 +176,10 @@ class FanChart(Report):
menu = options.menu
lang = options.menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
self.set_locale(options.menu.get_option_by_name('trans').get_value())
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, rlocale)
stdoptions.run_living_people_option(self, menu, self._locale)
self.database = CacheProxyDb(self.database)
self.max_generations = menu.get_option_by_name('maxgen').get_value()

View File

@ -740,13 +740,13 @@ class StatisticsChart(Report):
menu = options.menu
self._user = user
lang = menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
# override default gettext, or English output will have "person|Title"
self._ = rlocale.translation.sgettext
self._ = self._locale.translation.sgettext
stdoptions.run_private_data_option(self, menu)
living_opt = stdoptions.run_living_people_option(self, menu, rlocale)
living_opt = stdoptions.run_living_people_option(self, menu,
self._locale)
self.database = CacheProxyDb(self.database)
get_option_by_name = menu.get_option_by_name
@ -754,7 +754,7 @@ class StatisticsChart(Report):
filter_opt = get_option_by_name('filter')
self.filter = filter_opt.get_filter()
self.fil_name = "(%s)" % self.filter.get_name(rlocale)
self.fil_name = "(%s)" % self.filter.get_name(self._locale)
self.bar_items = get_value('bar_items')
year_from = get_value('year_from')
@ -805,7 +805,7 @@ class StatisticsChart(Report):
gender, year_from, year_to,
get_value('no_years'),
self._user.step_progress,
rlocale)
self._locale)
self._user.end_progress()
self._user.begin_progress(_('Statistics Charts'),

View File

@ -99,15 +99,15 @@ class TimeLine(Report):
self._user = user
menu = options.menu
lang = options.menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
self.set_locale(options.menu.get_option_by_name('trans').get_value())
stdoptions.run_private_data_option(self, menu)
living_opt = stdoptions.run_living_people_option(self, menu, rlocale)
living_opt = stdoptions.run_living_people_option(self, menu,
self._locale)
self.database = CacheProxyDb(self.database)
self.filter = menu.get_option_by_name('filter').get_filter()
self.fil_name = "(%s)" % self.filter.get_name(rlocale)
self.fil_name = "(%s)" % self.filter.get_name(self._locale)
living_value = menu.get_option_by_name('living_people').get_value()
for (value, description) in living_opt.get_items(xml_items=True):

View File

@ -174,7 +174,9 @@ class FamilyLinesOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
# --------------------------------
add_option = partial(menu.add_option, _('People of Interest'))
@ -344,8 +346,9 @@ class FamilyLinesReport(Report):
get_option_by_name = menu.get_option_by_name
get_value = lambda name: get_option_by_name(name).get_value()
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)

View File

@ -85,11 +85,12 @@ class HourGlassReport(Report):
Report.__init__(self, database, options, user)
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
locale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, locale)
stdoptions.run_living_people_option(self, menu, self._locale)
self.database = CacheProxyDb(self.database)
self.__db = self.database
@ -359,7 +360,9 @@ class HourGlassOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
################################
category_name = _("Graph Style")

View File

@ -128,8 +128,9 @@ class RelGraphReport(Report):
get_option_by_name = options.menu.get_option_by_name
get_value = lambda name: get_option_by_name(name).get_value()
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
@ -800,7 +801,9 @@ class RelGraphOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
################################
add_option = partial(menu.add_option, _("Include"))

View File

@ -309,7 +309,6 @@ class DateFormat(GenericFormat):
def modifier():
#ui_mods taken from date.py def lookup_modifier(self, modifier):
# trans_text is a defined keyword (in po/update_po.py, po/genpot.sh)
# (in po/update_po.py, po/genpot.sh)
trans_text = self._locale.translation.gettext
ui_mods = ["", trans_text("before"), trans_text("after"),
trans_text("about"), "", "", ""]

View File

@ -96,11 +96,12 @@ class AncestorReport(Report):
self.map = {}
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, rlocale)
stdoptions.run_living_people_option(self, menu, self._locale)
self.database = CacheProxyDb(self.database)
self.max_generations = menu.get_option_by_name('maxgen').get_value()
@ -114,7 +115,7 @@ class AncestorReport(Report):
stdoptions.run_name_format_option(self, menu)
self.__narrator = Narrator(self.database, use_fulldate=True,
nlocale=rlocale)
nlocale=self._locale)
def apply_filter(self, person_handle, index, generation=1):
"""
@ -305,7 +306,9 @@ class AncestorOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
def make_default_style(self, default_style):
"""

View File

@ -102,8 +102,7 @@ class BirthdayReport(Report):
self.filter = self.filter_option.get_filter()
pid = mgobn('pid')
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_name_format_option(self, menu)

View File

@ -426,8 +426,9 @@ class DescendantReport(Report):
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
@ -544,7 +545,9 @@ class DescendantOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
def make_default_style(self, default_style):
"""Make the default output style for the Descendant Report."""

View File

@ -124,8 +124,9 @@ class DetAncestorReport(Report):
get_option_by_name = menu.get_option_by_name
get_value = lambda name: get_option_by_name(name).get_value()
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
@ -839,7 +840,9 @@ class DetAncestorOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category)
stdoptions.add_localization_option(menu, category)
locale_opt = stdoptions.add_localization_option(menu, category)
stdoptions.add_date_format_option(menu, category, locale_opt)
# Content options

View File

@ -140,7 +140,9 @@ 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'))
self.set_locale(get_value('trans'))
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
@ -1044,7 +1046,9 @@ class DetDescendantOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category)
stdoptions.add_localization_option(menu, category)
locale_opt = stdoptions.add_localization_option(menu, category)
stdoptions.add_date_format_option(menu, category, locale_opt)
# Content

View File

@ -77,11 +77,12 @@ class EndOfLineReport(Report):
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, rlocale)
stdoptions.run_living_people_option(self, menu, self._locale)
self.database = CacheProxyDb(self.database)
pid = menu.get_option_by_name('pid').get_value()
@ -278,7 +279,9 @@ class EndOfLineOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
def make_default_style(self, default_style):
"""Make the default output style for the End of Line Report."""

View File

@ -86,10 +86,11 @@ 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.set_locale(menu.get_option_by_name('trans').get_value())
self._ = self._locale.translation.sgettext # needed for English
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
self.database = CacheProxyDb(self.database)
@ -734,7 +735,9 @@ class FamilyGroupOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
##########################
add_option = partial(menu.add_option, _("Include"))

View File

@ -128,8 +128,7 @@ class IndivCompleteReport(Report):
self._user = user
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)

View File

@ -86,11 +86,12 @@ class KinshipReport(Report):
Report.__init__(self, database, options, user)
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, rlocale)
stdoptions.run_living_people_option(self, menu, self._locale)
self.database = CacheProxyDb(self.database)
self.__db = self.database
@ -107,7 +108,7 @@ class KinshipReport(Report):
stdoptions.run_name_format_option(self, menu)
self.rel_calc = get_relationship_calculator(reinit=True,
clocale=rlocale)
clocale=self._locale)
self.kinship_map = {}
self.spouse_map = {}
@ -386,7 +387,9 @@ class KinshipOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
def make_default_style(self, default_style):
"""Make the default output style for the Kinship Report."""

View File

@ -83,8 +83,7 @@ class NumberOfAncestorsReport(Report):
if self.__person is None:
raise ReportError(_("Person %s is not in the Database") % pid)
lang = options.menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self.set_locale(options.menu.get_option_by_name('trans').get_value())
stdoptions.run_name_format_option(self, options.menu)

View File

@ -81,11 +81,13 @@ class PlaceReport(Report):
self._user = user
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
living_opt = stdoptions.run_living_people_option(self, menu, rlocale)
living_opt = stdoptions.run_living_people_option(self, menu,
self._locale)
self.database = CacheProxyDb(self.database)
self._db = self.database
@ -461,7 +463,9 @@ class PlaceOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
def make_default_style(self, default_style):
"""

View File

@ -75,8 +75,7 @@ class RecordsReport(Report):
Report.__init__(self, database, options, user)
menu = options.menu
lang = options.menu.get_option_by_name('trans').get_value()
self._locale = self.set_locale(lang)
self.set_locale(options.menu.get_option_by_name('trans').get_value())
stdoptions.run_private_data_option(self, menu)
living_opt = stdoptions.run_living_people_option(self, menu,

View File

@ -75,11 +75,10 @@ class SummaryReport(Report):
"""
Report.__init__(self, database, options, user)
lang = options.menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
self.set_locale(options.menu.get_option_by_name('trans').get_value())
stdoptions.run_private_data_option(self, options.menu)
stdoptions.run_living_people_option(self, options.menu, rlocale)
stdoptions.run_living_people_option(self, options.menu, self._locale)
self.database = CacheProxyDb(self.database)
self.__db = self.database

View File

@ -83,11 +83,13 @@ class TagReport(Report):
Report.__init__(self, database, options, user)
menu = options.menu
lang = menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
living_opt = stdoptions.run_living_people_option(self, menu, rlocale)
living_opt = stdoptions.run_living_people_option(self, menu,
self._locale)
self.database = CacheProxyDb(self.database)
self._lv = menu.get_option_by_name('living_people').get_value()
@ -915,7 +917,9 @@ class TagOptions(MenuReportOptions):
stdoptions.add_living_people_option(menu, category_name)
stdoptions.add_localization_option(menu, category_name)
locale_opt = stdoptions.add_localization_option(menu, category_name)
stdoptions.add_date_format_option(menu, category_name, locale_opt)
def make_default_style(self, default_style):
"""Make the default output style for the Tag Report."""