7124: Complete Individual Report does incomplete translation
svn: r23353
This commit is contained in:
parent
e8f7341fb5
commit
2bf775fad3
@ -31,7 +31,7 @@ from ..docgen import FontStyle, ParagraphStyle, FONT_SANS_SERIF
|
||||
from ...lib import NoteType, Citation
|
||||
from ...const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from ...utils.string import confidence
|
||||
from ...utils.string import conf_strings
|
||||
|
||||
def add_endnote_styles(style_sheet):
|
||||
"""
|
||||
@ -198,21 +198,9 @@ def _format_ref_text(ref, key, elocale):
|
||||
ref_txt = ref.get_page()
|
||||
|
||||
# Print only confidence level if it is not Normal
|
||||
if (ref.get_confidence_level() != Citation.CONF_NORMAL
|
||||
and elocale == glocale): # FIXME
|
||||
# the correct fix would be to enable deferred translation for at
|
||||
# least the "confidence" list of strings (in gen/utils/string.py),
|
||||
# and possibly others too if they need deferred translation, but that
|
||||
# would require searching out every use of a "confidence" string and
|
||||
# translating it there, either to the UI language or to a "deferred"
|
||||
# language (e.g. when used in a report, as here in this module), but
|
||||
# that would require an immense amount of time and testing and since
|
||||
# a release is imminent this is not the time to consider that, so I
|
||||
# have instead added the above line, which will disable the typeout
|
||||
# of any "confidence" rating /if/ a translated value is needed, while
|
||||
# continuing to show the "confidence" for the normal case of a user
|
||||
# running a report in their own language (when elocale==glocale)
|
||||
ref_txt += " [" + confidence[ref.get_confidence_level()] + "]"
|
||||
if ref.get_confidence_level() != Citation.CONF_NORMAL:
|
||||
ref_txt += " [" + elocale.translation.gettext(
|
||||
conf_strings[ref.get_confidence_level()]) + "]"
|
||||
|
||||
return ref_txt
|
||||
|
||||
|
@ -35,6 +35,10 @@ from ..lib import Person, Citation, FamilyRelType
|
||||
from ..const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
|
||||
def _T_(value): # enable deferred translations (see Python docs 22.1.3.4)
|
||||
return value
|
||||
# _T_ is a gramps-defined keyword -- see po/update_po.py and po/genpot.sh
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Integer to String mappings for constants
|
||||
@ -49,13 +53,15 @@ gender = {
|
||||
def format_gender( type):
|
||||
return gender.get(type[0], _("Invalid"))
|
||||
|
||||
confidence = {
|
||||
Citation.CONF_VERY_HIGH : _("Very High"),
|
||||
Citation.CONF_HIGH : _("High"),
|
||||
Citation.CONF_NORMAL : _("Normal"),
|
||||
Citation.CONF_LOW : _("Low"),
|
||||
Citation.CONF_VERY_LOW : _("Very Low"),
|
||||
}
|
||||
conf_strings = {
|
||||
Citation.CONF_VERY_HIGH : _T_("Very High"),
|
||||
Citation.CONF_HIGH : _T_("High"),
|
||||
Citation.CONF_NORMAL : _T_("Normal"),
|
||||
Citation.CONF_LOW : _T_("Low"),
|
||||
Citation.CONF_VERY_LOW : _T_("Very Low"),
|
||||
}
|
||||
# note that a list /very/ similar to this is in EditCitation._setup_fields
|
||||
# but that has the glocale's translated values since it is used in the UI
|
||||
|
||||
family_rel_descriptions = {
|
||||
FamilyRelType.MARRIED : _("A legal or common-law relationship "
|
||||
|
@ -53,8 +53,10 @@ from gi.repository import GObject
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
from gramps.gen.filters import (GenericFilterFactory, FilterList,
|
||||
reload_custom_filters)
|
||||
reload_custom_filters)
|
||||
from gramps.gen.filters.rules._matchesfilterbase import MatchesFilterBase
|
||||
from ..listmodel import ListModel
|
||||
from ..managedwindow import ManagedWindow
|
||||
@ -62,15 +64,14 @@ from ..dialog import QuestionDialog
|
||||
from gramps.gen.const import RULE_GLADE, URL_MANUAL_PAGE
|
||||
from ..display import display_help
|
||||
from gramps.gen.errors import WindowActiveError
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.sgettext
|
||||
from gramps.gen.lib import AttributeType, EventType, FamilyRelType, NameOriginType, NameType, NoteType
|
||||
from gramps.gen.lib import (AttributeType, EventType, FamilyRelType,
|
||||
NameOriginType, NameType, NoteType)
|
||||
from gramps.gen.filters import rules
|
||||
from ..autocomp import StandardCustomSelector, fill_entry
|
||||
from ..selectors import SelectorFactory
|
||||
from gramps.gen.display.name import displayer as _nd
|
||||
from gramps.gen.utils.db import family_name
|
||||
from gramps.gen.utils.string import confidence
|
||||
from gramps.gen.utils.string import conf_strings
|
||||
from gramps.gen.constfunc import cuni
|
||||
from ..widgets import DateEntry
|
||||
|
||||
@ -553,7 +554,7 @@ class EditRule(ManagedWindow):
|
||||
t = MyList(taglist, taglist)
|
||||
elif v == _('Confidence level:'):
|
||||
t = MyList(list(map(str, list(range(5)))),
|
||||
[confidence[i] for i in range(5)])
|
||||
[_(conf_strings[i]) for i in range(5)])
|
||||
elif v == _('Date:'):
|
||||
t = DateEntry(self.uistate, self.track)
|
||||
else:
|
||||
|
@ -50,7 +50,7 @@ from gramps.gen.filters import GenericFilterFactory, rules
|
||||
from gramps.gen.filters.rules.citation import (RegExpIdOf, HasCitation,
|
||||
HasNoteRegexp, MatchesFilter,
|
||||
HasSource, RegExpSourceIdOf)
|
||||
from gramps.gen.utils.string import confidence
|
||||
from gramps.gen.utils.string import conf_strings
|
||||
GenericCitationFilter = GenericFilterFactory('Citation')
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -73,10 +73,10 @@ class CitationSidebarFilter(SidebarFilter):
|
||||
|
||||
self.filter_conf = Gtk.ComboBox()
|
||||
model = Gtk.ListStore(str)
|
||||
for conf_value in sorted(confidence.keys()):
|
||||
model.append((confidence[conf_value],))
|
||||
for conf_value in sorted(conf_strings.keys()):
|
||||
model.append((_(conf_strings[conf_value]),))
|
||||
self.filter_conf.set_model(model)
|
||||
self.filter_conf.set_active(2) # Citation.CONF_NORMAL
|
||||
self.filter_conf.set_active(Citation.CONF_NORMAL)
|
||||
|
||||
self.filter_note = Gtk.Entry()
|
||||
|
||||
@ -124,7 +124,7 @@ class CitationSidebarFilter(SidebarFilter):
|
||||
self.filter_id.set_text('')
|
||||
self.filter_page.set_text('')
|
||||
self.filter_date.set_text('')
|
||||
self.filter_conf.set_active(2)
|
||||
self.filter_conf.set_active(Citation.CONF_NORMAL)
|
||||
self.filter_note.set_text('')
|
||||
self.generic.set_active(0)
|
||||
|
||||
@ -144,9 +144,9 @@ class CitationSidebarFilter(SidebarFilter):
|
||||
model = self.filter_conf.get_model()
|
||||
node = self.filter_conf.get_active_iter()
|
||||
conf_name = model.get_value(node, 0) # The value is actually the text
|
||||
conf = 2
|
||||
for i in list(confidence.keys()):
|
||||
if confidence[i] == conf_name:
|
||||
conf = Citation.CONF_NORMAL
|
||||
for i in list(conf_strings.keys()):
|
||||
if _(conf_strings[i]) == conf_name:
|
||||
conf = i
|
||||
break
|
||||
# conf = self.citn.get_confidence_level()
|
||||
|
@ -36,7 +36,7 @@ from gramps.gen.const import URL_MANUAL_PAGE
|
||||
from ..display import display_help
|
||||
from ..managedwindow import ManagedWindow
|
||||
from gramps.gen.datehandler import get_date
|
||||
from gramps.gen.utils.string import confidence
|
||||
from gramps.gen.utils.string import conf_strings
|
||||
from gramps.gen.merge import MergeCitationQuery
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -92,8 +92,8 @@ class MergeCitation(ManagedWindow):
|
||||
|
||||
entry1 = self.get_widget("confidence1")
|
||||
entry2 = self.get_widget("confidence2")
|
||||
entry1.set_text(confidence[self.citation1.get_confidence_level()])
|
||||
entry2.set_text(confidence[self.citation2.get_confidence_level()])
|
||||
entry1.set_text(_(conf_strings[self.citation1.get_confidence_level()]))
|
||||
entry2.set_text(_(conf_strings[self.citation2.get_confidence_level()]))
|
||||
if entry1.get_text() == entry2.get_text():
|
||||
for widget_name in ('confidence1', 'confidence2', 'confidence_btn1',
|
||||
'confidence_btn2'):
|
||||
|
@ -39,12 +39,13 @@ LOG = logging.getLogger(".citation")
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
_ = glocale.translation.gettext
|
||||
from gramps.gen.datehandler import format_time, get_date, get_date_valid
|
||||
from gramps.gen.lib import Citation
|
||||
from gramps.gen.utils.string import confidence
|
||||
from gramps.gen.utils.string import conf_strings
|
||||
from gramps.gen.config import config
|
||||
from gramps.gen.constfunc import cuni
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -114,7 +115,7 @@ class CitationBaseModel(object):
|
||||
return cuni(data[COLUMN_PAGE])
|
||||
|
||||
def citation_confidence(self, data):
|
||||
return cuni(confidence[data[COLUMN_CONFIDENCE]])
|
||||
return cuni(_(conf_strings[data[COLUMN_CONFIDENCE]]))
|
||||
|
||||
def citation_private(self, data):
|
||||
if data[COLUMN_PRIV]:
|
||||
|
@ -223,7 +223,7 @@ class IndivCompleteReport(Report):
|
||||
# Groups with more than one type
|
||||
column_1 = self._(self._get_type(event.get_type()))
|
||||
if role not in (EventRoleType.PRIMARY, EventRoleType.FAMILY):
|
||||
column_1 = column_1 + ' (' + str(role) + ')'
|
||||
column_1 = column_1 + ' (' + self._(role.xml_str()) + ')'
|
||||
column_2 = combine('%s, %s', '%s', description, date_place)
|
||||
else:
|
||||
# Groups with a single type (remove event type from first column)
|
||||
|
@ -47,7 +47,7 @@ from gi.repository import Gtk
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gramps.gen.utils.string import confidence
|
||||
from gramps.gen.utils.string import conf_strings
|
||||
from gramps.gen.const import URL_MANUAL_PAGE
|
||||
from gramps.gui.utils import ProgressMeter
|
||||
from gramps.gui.plug import tool
|
||||
@ -203,7 +203,7 @@ class MergeCitations(tool.BatchTool,ManagedWindow):
|
||||
key += "\n" + get_date(citation)
|
||||
if fields != IGNORE_CONFIDENCE and fields != IGNORE_BOTH:
|
||||
key += "\n" + \
|
||||
confidence[citation.get_confidence_level()]
|
||||
conf_strings[citation.get_confidence_level()]
|
||||
if key in dict and \
|
||||
(not dont_merge_notes or len(citation.note_list) == 0):
|
||||
citation_match_handle = dict[key]
|
||||
|
@ -56,7 +56,7 @@ from gramps.gen.lib import StyledText, StyledTextTag, StyledTextTagType
|
||||
from gramps.gen.db import DbTxn
|
||||
from gramps.gen.mime import get_type
|
||||
from gramps.gui.plug import tool
|
||||
from gramps.gen.utils.string import confidence
|
||||
from gramps.gen.utils.string import conf_strings
|
||||
from gramps.gui.utils import ProgressMeter
|
||||
from gramps.gen.utils.lds import TEMPLES
|
||||
from gramps.gen.db.dbconst import *
|
||||
@ -1722,7 +1722,7 @@ class TestcaseGenerator(tool.BatchTool):
|
||||
#if randint(0,1) == 1:
|
||||
# (year, d) = self.rand_date( )
|
||||
# o.set_date_object( d)
|
||||
o.set_confidence_level(choice(list(confidence.keys())))
|
||||
o.set_confidence_level(choice(list(conf_strings.keys())))
|
||||
|
||||
if issubclass(o.__class__,gen.lib.tagbase.TagBase):
|
||||
if randint(0,1) == 1:
|
||||
|
@ -122,7 +122,7 @@ from gramps.gen.plug.report import utils as ReportUtils
|
||||
from gramps.gen.plug.report import MenuReportOptions
|
||||
|
||||
from gramps.gen.utils.config import get_researcher
|
||||
from gramps.gen.utils.string import confidence
|
||||
from gramps.gen.utils.string import conf_strings
|
||||
from gramps.gen.utils.file import media_path_full
|
||||
from gramps.gen.utils.alive import probably_alive
|
||||
from gramps.gen.utils.db import get_source_and_citation_referents
|
||||
@ -2364,9 +2364,11 @@ class BasePage(object):
|
||||
for key, sref in citation_ref_list:
|
||||
cit_ref_li = Html("li", id="sref%d%s" % (cindex, key))
|
||||
tmp = Html("ul")
|
||||
conf = confidence.get(sref.confidence, _('Unknown'))
|
||||
if conf == _('Normal'):
|
||||
conf = conf_strings.get(sref.confidence, _('Unknown'))
|
||||
if conf == conf_strings[Citation.CONF_NORMAL]:
|
||||
conf = None
|
||||
else:
|
||||
conf = _(conf)
|
||||
for (label, data) in [
|
||||
[_("Date"), _dd.display(sref.date)],
|
||||
[_("Page"), sref.page],
|
||||
|
Loading…
Reference in New Issue
Block a user