add translated-output option to B.R. TOC and Index reports

This commit is contained in:
Paul Franklin 2014-06-14 13:39:28 -07:00
parent d633c7711d
commit 176493c011
4 changed files with 26 additions and 22 deletions

View File

@ -235,7 +235,7 @@ def write_toc(toc, doc):
return
doc.start_paragraph('TOC-Title')
doc.write_text(_('Contents'))
doc.write_text(doc.toc_title)
doc.end_paragraph()
doc.start_table('toc', 'TOC-Table')
@ -268,7 +268,7 @@ def write_index(index, doc):
return
doc.start_paragraph('IDX-Title')
doc.write_text(_('Index'))
doc.write_text(doc.index_title)
doc.end_paragraph()
doc.start_table('index', 'IDX-Table')

View File

@ -1631,7 +1631,7 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
"""
Insert a Table of Contents at this point in the document.
"""
title = _('Contents')
title = self.toc_title
self.cntnt.write('<text:table-of-content>')
self.cntnt.write('<text:table-of-content-source ' +
@ -1670,7 +1670,7 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc):
"""
Insert an Alphabetical Index at this point in the document.
"""
title = _('Index')
title = self.index_title
self.cntnt.write('<text:alphabetical-index>')
self.cntnt.write('<text:alphabetical-index-source ' +
'text:ignore-case="true" ' +

View File

@ -1,7 +1,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2012 Nick Hall
# Copyright (C) 2012 Paul Franklin
# Copyright (C) 2012-2014 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
@ -23,19 +23,20 @@
# Python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.plug.report import Report
from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions
from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, TableStyle,
TableCellStyle, FONT_SANS_SERIF,
IndexMark, INDEX_TYPE_TOC)
TableCellStyle, FONT_SANS_SERIF,
IndexMark, INDEX_TYPE_TOC)
#------------------------------------------------------------------------
#
@ -56,15 +57,15 @@ class AlphabeticalIndex(Report):
"""
Report.__init__(self, database, options, user)
self._user = user
self.set_locale(options.menu.get_option_by_name('trans').get_value())
menu = options.menu
def write_report(self):
""" Generate the contents of the report """
mark = IndexMark(_("Alphabetical Index"), INDEX_TYPE_TOC, 1)
mark = IndexMark(self._("Alphabetical Index"), INDEX_TYPE_TOC, 1)
self.doc.start_paragraph("IDX-Title")
self.doc.write_text('', mark)
self.doc.end_paragraph()
self.doc.index_title = self._('Index')
self.doc.insert_index()
#------------------------------------------------------------------------
@ -84,7 +85,8 @@ class AlphabeticalIndexOptions(MenuReportOptions):
def add_menu_options(self, menu):
""" Add the options for this report """
pass
category_name = _("Report Options")
stdoptions.add_localization_option(menu, category_name)
def make_default_style(self, default_style):
"""Make the default output style for the AlphabeticalIndex report."""

View File

@ -1,7 +1,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2012 Nick Hall
# Copyright (C) 2012 Paul Franklin
# Copyright (C) 2012-2014 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
@ -23,19 +23,20 @@
# Python modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#------------------------------------------------------------------------
#
# Gramps modules
#
#------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
from gramps.gen.plug.report import Report
from gramps.gen.plug.report import MenuReportOptions
from gramps.gen.plug.report import stdoptions
from gramps.gen.plug.docgen import (FontStyle, ParagraphStyle, TableStyle,
TableCellStyle, FONT_SANS_SERIF,
IndexMark, INDEX_TYPE_TOC)
TableCellStyle, FONT_SANS_SERIF,
IndexMark, INDEX_TYPE_TOC)
#------------------------------------------------------------------------
#
@ -56,15 +57,15 @@ class TableOfContents(Report):
"""
Report.__init__(self, database, options, user)
self._user = user
self.set_locale(options.menu.get_option_by_name('trans').get_value())
menu = options.menu
def write_report(self):
""" Generate the contents of the report """
mark = IndexMark(_("Table Of Contents"), INDEX_TYPE_TOC, 1)
mark = IndexMark(self._("Table Of Contents"), INDEX_TYPE_TOC, 1)
self.doc.start_paragraph("TOC-Title")
self.doc.write_text('', mark)
self.doc.end_paragraph()
self.doc.toc_title = self._('Contents')
self.doc.insert_toc()
#------------------------------------------------------------------------
@ -84,7 +85,8 @@ class TableOfContentsOptions(MenuReportOptions):
def add_menu_options(self, menu):
""" Add the options for this report """
pass
category_name = _("Report Options")
stdoptions.add_localization_option(menu, category_name)
def make_default_style(self, default_style):
"""Make the default output style for the TableOfContents report."""