From 5a1694b98122e3ac19e941399c6b8dafebcacf3f Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Sun, 16 Feb 2014 11:16:47 -0800 Subject: [PATCH] translate some paper names, suggested in 0566 --- po/POTFILES.in | 1 + po/POTFILES.skip | 1 - src/cli/plug/__init__.py | 2 +- src/gen/plug/docgen/paperstyle.py | 9 +++++++++ src/gen/plug/report/_paper.py | 4 ++-- src/gui/plug/report/_papermenu.py | 18 +++++++++++------- 6 files changed, 24 insertions(+), 11 deletions(-) diff --git a/po/POTFILES.in b/po/POTFILES.in index c5cb0be34..0c1670c96 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -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 diff --git a/po/POTFILES.skip b/po/POTFILES.skip index d9ea4fe42..5ada3f128 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -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 diff --git a/src/cli/plug/__init__.py b/src/cli/plug/__init__.py index e220f7a73..ef29a6e44 100644 --- a/src/cli/plug/__init__.py +++ b/src/cli/plug/__init__.py @@ -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, diff --git a/src/gen/plug/docgen/paperstyle.py b/src/gen/plug/docgen/paperstyle.py index 902fa1ff5..c93a50556 100644 --- a/src/gen/plug/docgen/paperstyle.py +++ b/src/gen/plug/docgen/paperstyle.py @@ -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" diff --git a/src/gen/plug/report/_paper.py b/src/gen/plug/report/_paper.py index 6ff97af25..1ed879a65 100644 --- a/src/gen/plug/report/_paper.py +++ b/src/gen/plug/report/_paper.py @@ -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 ] diff --git a/src/gui/plug/report/_papermenu.py b/src/gui/plug/report/_papermenu.py index 85cc50a2b..921a93d71 100644 --- a/src/gui/plug/report/_papermenu.py +++ b/src/gui/plug/report/_papermenu.py @@ -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(",", ".") ))