translate some paper names, suggested in 0566

This commit is contained in:
Paul Franklin 2014-02-16 11:19:13 -08:00
parent 88f98b6bf9
commit a2807dff79
6 changed files with 25 additions and 11 deletions

View File

@ -309,7 +309,7 @@ class CommandLineReport(object):
self.options_help['papers'][2] = \
[ paper.get_name() for paper in paper_sizes
if paper.get_name() != _("Custom Size") ]
if paper.get_name() != 'Custom Size' ]
self.options_help['papero'][2] = [
"%d\tPortrait" % PAPER_PORTRAIT,

View File

@ -36,6 +36,8 @@
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.sgettext
#-------------------------------------------------------------------------
#
@ -74,6 +76,14 @@ class PaperSize(object):
self.name = name
self.height = height
self.width = width
if self.name == 'Letter':
self.trans_pname = _('paper size|Letter')
elif self.name == 'Legal':
self.trans_pname = _('paper size|Legal')
elif self.name == 'Custom Size':
self.trans_pname = _('Custom Size')
else:
self.trans_pname = None
def get_name(self):
"Return the name of the paper style"

View File

@ -88,7 +88,7 @@ try:
the_file = open(PAPERSIZE)
parser.parse(the_file)
the_file.close()
paper_sizes.append(PaperSize(_("Custom Size"), -1, -1))
paper_sizes.append(PaperSize("Custom Size", -1, -1)) # always in English
except (IOError, OSError, SAXParseException):
paper_sizes = [
PaperSize("Letter",27.94,21.59),
@ -110,5 +110,5 @@ except (IOError, OSError, SAXParseException):
PaperSize("C",55.88,43.18),
PaperSize("D",86.36, 55.88),
PaperSize("E",111.76,86.36),
PaperSize(_("Custom Size"),-1,-1)
PaperSize("Custom Size",-1,-1) # always in English
]

View File

@ -68,10 +68,13 @@ class PaperComboBox(Gtk.ComboBox):
index = 0
start_index = 0
for key in paper_sizes:
self.mapping[key.get_name()] = key
self.store.append(row=[key.get_name()])
if key.get_name() == default_name:
key_name = key.get_name()
if default_name == key_name or default_name == key.trans_pname:
start_index = index
self.mapping[key_name] = key # always use the English paper name
if key.trans_pname:
key_name = key.trans_pname # display the translated paper name
self.store.append(row=[key_name])
index += 1
self.set_active(start_index)
@ -81,6 +84,9 @@ class PaperComboBox(Gtk.ComboBox):
if active < 0:
return None
key = cuni(self.store[active][0])
for paper in paper_sizes:
if key == paper.trans_pname:
key = paper.get_name()
return (self.mapping[key],key)
#-------------------------------------------------------------------------
@ -182,7 +188,7 @@ class PaperFrame(Gtk.HBox):
"""Paper size combobox 'changed' callback."""
size, name = self.get_paper_size()
is_custom = name == _("Custom Size")
is_custom = name == "Custom Size"
self.pwidth.set_sensitive(is_custom)
self.pheight.set_sensitive(is_custom)
@ -241,9 +247,7 @@ class PaperFrame(Gtk.HBox):
"""
papersize, papername = self.papersize_menu.get_value()
# FIXME it is wrong to use translatable text in comparison.
# How can we distinguish custom size though?
if papername == _('Custom Size'):
if papername == 'Custom Size':
try:
h = float(cuni(self.pheight.get_text().replace(",", ".")))
w = float(cuni(self.pwidth.get_text().replace(",", ".") ))

View File

@ -310,6 +310,7 @@ gramps/gen/plug/_options.py
gramps/gen/plug/_pluginreg.py
gramps/gen/plug/docbackend/docbackend.py
gramps/gen/plug/docgen/graphdoc.py
gramps/gen/plug/docgen/paperstyle.py
gramps/gen/plug/menu/_enumeratedlist.py
gramps/gen/plug/report/_book.py
gramps/gen/plug/report/_constants.py

View File

@ -219,7 +219,6 @@ gramps/gen/plug/docgen/fontscale.py
gramps/gen/plug/docgen/fontstyle.py
gramps/gen/plug/docgen/graphicstyle.py
gramps/gen/plug/docgen/__init__.py
gramps/gen/plug/docgen/paperstyle.py
gramps/gen/plug/docgen/paragraphstyle.py
gramps/gen/plug/docgen/stylesheet.py
gramps/gen/plug/docgen/tablestyle.py