make "update_po -p" happier about unnamed strings

This commit is contained in:
Paul Franklin 2014-04-14 17:07:32 -07:00
parent a2d23d0201
commit 99cfe782da
7 changed files with 58 additions and 38 deletions

View File

@ -325,9 +325,11 @@ class ArgParser(object):
set_value = True
if config.has_default(setting_name):
setting_value = config.get(setting_name)
print(_("Current Gramps config setting: %s:%s")
% (setting_name, repr(setting_value)),
file=sys.stderr)
print(_("Current Gramps config setting: "
"%(name)s:%(value)s")
% {'name' : setting_name,
'value' : repr(setting_value)},
file=sys.stderr)
if set_value:
# does a user want the default config value?
if new_value in ("DEFAULT", _("DEFAULT")):
@ -337,10 +339,12 @@ class ArgParser(object):
new_value = converter(new_value)
config.set(setting_name, new_value)
# translators: indent "New" to match "Current"
print(_(" New Gramps config setting: %s:%s")
% (setting_name,
repr(config.get(setting_name))),
file=sys.stderr)
print(_(" New Gramps config setting: "
"%(name)s:%(value)s") %
{'name' : setting_name,
'value' : repr(
config.get(setting_name))},
file=sys.stderr)
else:
need_to_quit = True
else:

View File

@ -466,10 +466,11 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase,
surname = self.get_surname()
if self.suffix:
# translators: needed for Arabic, ignore otherwise
return _("%s, %s %s") % (surname, first, self.suffix)
return _("%(surname)s, %(first)s %(suffix)s"
) % {'surname':surname, 'first':first, 'suffix':self.suffix}
else:
# translators: needed for Arabic, ignore otherwise
return _("%s, %s") % (surname, first)
return _("%(str1)s, %(str2)s") % {'str1':surname, 'str2':first}
def get_upper_name(self):
"""
@ -480,10 +481,11 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase,
surname = self.get_surname().upper()
if self.suffix:
# translators: needed for Arabic, ignore otherwise
return _("%s, %s %s") % (surname, first, self.suffix)
return _("%(surname)s, %(first)s %(suffix)s"
) % {'surname':surname, 'first':first, 'suffix':self.suffix}
else:
# translators: needed for Arabic, ignore otherwise
return _("%s, %s") % (surname, first)
return _("%(str1)s, %(str2)s") % {'str1':surname, 'str2':first}
def get_regular_name(self):
"""
@ -496,7 +498,8 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase,
return "%s %s" % (first, surname)
else:
# translators: needed for Arabic, ignore otherwise
return _("%s %s, %s") % (first, surname, self.suffix)
return _("%(first)s %(surname)s, %(suffix)s"
) % {'surname':surname, 'first':first, 'suffix':self.suffix}
def get_gedcom_parts(self):
"""

View File

@ -233,7 +233,7 @@ def get_address_str(addr):
str = info
else:
# translators: needed for Arabic, ignore otherwise
str = _("%s, %s") % (str, info)
str = _("%(str1)s, %(str2)s") % {'str1':str, 'str2':info}
return str
#-------------------------------------------------------------------------

View File

@ -80,7 +80,9 @@ def run(database, document, date):
dead_matches += 1
document.has_data = (alive_matches + dead_matches) > 0
sdoc.paragraph(_("\nLiving matches: %d, Deceased matches: %d\n") % (alive_matches, dead_matches))
sdoc.paragraph(_("\nLiving matches: %(alive)d, "
"Deceased matches: %(dead)d\n") %
{'alive' : alive_matches, 'dead' : dead_matches})
stab.write(sdoc)
sdoc.paragraph("")

View File

@ -8,7 +8,7 @@
# Copyright (C) 2010 Jakim Friant
# Copyright (C) 2011 Tim G L Lyons
# Copyright (C) 2012 Mathieu MD
# Copyright (C) 2013 Paul Franklin
# Copyright (C) 2013-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
@ -155,7 +155,10 @@ class IndivCompleteReport(Report):
if place_handle:
place = self.database.get_place_from_handle(
place_handle).get_title()
date_place = combine(self._('%s in %s. '), '%s. ', date, place)
# make sure it's translated, so it can be used below, in "combine"
ignore1 = _('%(str1)s in %(str2)s. ') % {'str1':'', 'str2':''}
date_place = self.combine('%(str1)s in %(str2)s. ', '%s. ',
date, place)
if show_type:
# Groups with more than one type
@ -163,12 +166,18 @@ class IndivCompleteReport(Report):
if role not in (EventRoleType.PRIMARY, EventRoleType.FAMILY):
column_1 = column_1 + ' (' + self._(role.xml_str()) + ')'
# translators: needed for Arabic, ignore otherwise
column_2 = combine(self._('%s, %s'), '%s', description, date_place)
# make sure it's translated, so it can be used below, in "combine"
ignore2 = _('%(str1)s, %(str2)s') % {'str1':'', 'str2':''}
column_2 = self.combine('%(str1)s, %(str2)s', '%s',
description, date_place)
else:
# Groups with a single type (remove event type from first column)
column_1 = date
# translators: needed for Arabic, ignore otherwise
column_2 = combine(self._('%s, %s'), '%s', description, place)
# make sure it's translated, so it can be used below, in "combine"
ignore3 = _('%(str1)s, %(str2)s') % {'str1':'', 'str2':''}
column_2 = self.combine('%(str1)s, %(str2)s', '%s',
description, place)
endnotes = ""
if self.use_srcs:
@ -613,6 +622,17 @@ class IndivCompleteReport(Report):
printnotes=self.use_srcs_notes,
elocale=self._locale)
def combine(self, format_both, format_single, str1, str2):
""" Combine two strings with a given format. """
text = ""
if str1 and str2:
text = self._(format_both) % {'str1':str1, 'str2':str2}
elif str1 and not str2:
text = format_single % str1
elif str2 and not str1:
text = format_single % str2
return text
#------------------------------------------------------------------------
#
# IndivCompleteOptions
@ -792,19 +812,3 @@ class IndivCompleteOptions(MenuReportOptions):
default_style.add_table_style('IDS-PersonTable', tbl)
Endnotes.add_endnote_styles(default_style)
#------------------------------------------------------------------------
#
# Functions
#
#------------------------------------------------------------------------
def combine(format_both, format_single, str1, str2):
""" Combine two strings with a given format. """
text = ""
if str1 and str2:
text = format_both % (str1, str2)
elif str1 and not str2:
text = format_single % str1
elif str2 and not str1:
text = format_single % str2
return text

View File

@ -275,13 +275,19 @@ class Verify(tool.Tool, ManagedWindow, UpdateCallback):
(msg,gramps_id, name, the_type, rule_id, severity, handle) = results
if severity == Rule.WARNING:
# translators: needed for Arabic, ignore otherwise
print(_("W: %s, %s: %s, %s") % (msg, the_type, gramps_id, name))
print(_("%(severity)s: %(msg)s, %(type)s: %(gid)s, %(name)s") %
{'severity':'W', 'msg':msg, 'type':the_type,
'gid':gramps_id, 'name':name})
elif severity == Rule.ERROR:
# translators: needed for Arabic, ignore otherwise
print(_("E: %s, %s: %s, %s") % (msg, the_type, gramps_id, name))
print(_("%(severity)s: %(msg)s, %(type)s: %(gid)s, %(name)s") %
{'severity':'E', 'msg':msg, 'type':the_type,
'gid':gramps_id, 'name':name})
else:
# translators: needed for Arabic, ignore otherwise
print(_("S: %s, %s: %s, %s") % (msg, the_type,gramps_id, name))
print(_("%(severity)s: %(msg)s, %(type)s: %(gid)s, %(name)s") %
{'severity':'S', 'msg':msg, 'type':the_type,
'gid':gramps_id, 'name':name})
def init_gui(self):
# Draw dialog and make it handle everything

View File

@ -7365,7 +7365,8 @@ class NavWebReport(Report):
if husband and spouse:
husband_name = self.get_person_name(husband)
spouse_name = self.get_person_name(spouse)
title_str = _("Family of %s and %s") % (husband_name, spouse_name)
title_str = _("Family of %(husband)s and %(spouse)s") % {
'husband' : husband_name, 'spouse' : spouse_name}
elif husband:
husband_name = self.get_person_name(husband)
# Only the name of the husband is known