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] = \ self.options_help['papers'][2] = \
[ paper.get_name() for paper in paper_sizes [ 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] = [ self.options_help['papero'][2] = [
"%d\tPortrait" % PAPER_PORTRAIT, "%d\tPortrait" % PAPER_PORTRAIT,

View File

@ -36,6 +36,8 @@
# GRAMPS modules # 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.name = name
self.height = height self.height = height
self.width = width 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): def get_name(self):
"Return the name of the paper style" "Return the name of the paper style"

View File

@ -88,7 +88,7 @@ try:
the_file = open(PAPERSIZE) the_file = open(PAPERSIZE)
parser.parse(the_file) parser.parse(the_file)
the_file.close() 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): except (IOError, OSError, SAXParseException):
paper_sizes = [ paper_sizes = [
PaperSize("Letter",27.94,21.59), PaperSize("Letter",27.94,21.59),
@ -110,5 +110,5 @@ except (IOError, OSError, SAXParseException):
PaperSize("C",55.88,43.18), PaperSize("C",55.88,43.18),
PaperSize("D",86.36, 55.88), PaperSize("D",86.36, 55.88),
PaperSize("E",111.76,86.36), 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 index = 0
start_index = 0 start_index = 0
for key in paper_sizes: for key in paper_sizes:
self.mapping[key.get_name()] = key key_name = key.get_name()
self.store.append(row=[key.get_name()]) if default_name == key_name or default_name == key.trans_pname:
if key.get_name() == default_name:
start_index = index 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 index += 1
self.set_active(start_index) self.set_active(start_index)
@ -81,6 +84,9 @@ class PaperComboBox(Gtk.ComboBox):
if active < 0: if active < 0:
return None return None
key = cuni(self.store[active][0]) 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) return (self.mapping[key],key)
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -182,7 +188,7 @@ class PaperFrame(Gtk.HBox):
"""Paper size combobox 'changed' callback.""" """Paper size combobox 'changed' callback."""
size, name = self.get_paper_size() size, name = self.get_paper_size()
is_custom = name == _("Custom Size") is_custom = name == "Custom Size"
self.pwidth.set_sensitive(is_custom) self.pwidth.set_sensitive(is_custom)
self.pheight.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() papersize, papername = self.papersize_menu.get_value()
# FIXME it is wrong to use translatable text in comparison. if papername == 'Custom Size':
# How can we distinguish custom size though?
if papername == _('Custom Size'):
try: try:
h = float(cuni(self.pheight.get_text().replace(",", "."))) h = float(cuni(self.pheight.get_text().replace(",", ".")))
w = float(cuni(self.pwidth.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/_pluginreg.py
gramps/gen/plug/docbackend/docbackend.py gramps/gen/plug/docbackend/docbackend.py
gramps/gen/plug/docgen/graphdoc.py gramps/gen/plug/docgen/graphdoc.py
gramps/gen/plug/docgen/paperstyle.py
gramps/gen/plug/menu/_enumeratedlist.py gramps/gen/plug/menu/_enumeratedlist.py
gramps/gen/plug/report/_book.py gramps/gen/plug/report/_book.py
gramps/gen/plug/report/_constants.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/fontstyle.py
gramps/gen/plug/docgen/graphicstyle.py gramps/gen/plug/docgen/graphicstyle.py
gramps/gen/plug/docgen/__init__.py gramps/gen/plug/docgen/__init__.py
gramps/gen/plug/docgen/paperstyle.py
gramps/gen/plug/docgen/paragraphstyle.py gramps/gen/plug/docgen/paragraphstyle.py
gramps/gen/plug/docgen/stylesheet.py gramps/gen/plug/docgen/stylesheet.py
gramps/gen/plug/docgen/tablestyle.py gramps/gen/plug/docgen/tablestyle.py