translate some paper names, suggested in 0566

This commit is contained in:
Paul Franklin 2014-02-16 11:16:47 -08:00
parent 7434da9f63
commit 5a1694b981
6 changed files with 24 additions and 11 deletions

View File

@ -72,6 +72,7 @@ src/gen/plug/utils.py
# gen docgen API
src/gen/plug/docgen/graphdoc.py
src/gen/plug/docgen/paperstyle.py
# plugin report base API (was ReportBase)
src/gen/plug/report/_constants.py

View File

@ -186,7 +186,6 @@ src/gen/plug/docgen/fontscale.py
src/gen/plug/docgen/fontstyle.py
src/gen/plug/docgen/graphdoc.py
src/gen/plug/docgen/graphicstyle.py
src/gen/plug/docgen/paperstyle.py
src/gen/plug/docgen/paragraphstyle.py
src/gen/plug/docgen/stylesheet.py
src/gen/plug/docgen/tablestyle.py

View File

@ -299,7 +299,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,7 @@
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gen.ggettext import sgettext as _
#-------------------------------------------------------------------------
#
@ -74,6 +75,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(const.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

@ -65,10 +65,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)
@ -78,6 +81,9 @@ class PaperComboBox(gtk.ComboBox):
if active < 0:
return None
key = unicode(self.store[active][0])
for paper in paper_sizes:
if key == paper.trans_pname:
key = paper.get_name()
return (self.mapping[key],key)
#-------------------------------------------------------------------------
@ -179,7 +185,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)
@ -238,9 +244,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(unicode(self.pheight.get_text().replace(",", ".")))
w = float(unicode(self.pwidth.get_text().replace(",", ".") ))