From a2807dff796034738811dcb3a1edf5adf849bbb2 Mon Sep 17 00:00:00 2001 From: Paul Franklin Date: Sun, 16 Feb 2014 11:19:13 -0800 Subject: [PATCH] translate some paper names, suggested in 0566 --- gramps/cli/plug/__init__.py | 2 +- gramps/gen/plug/docgen/paperstyle.py | 10 ++++++++++ gramps/gen/plug/report/_paper.py | 4 ++-- gramps/gui/plug/report/_papermenu.py | 18 +++++++++++------- po/POTFILES.in | 1 + po/POTFILES.skip | 1 - 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/gramps/cli/plug/__init__.py b/gramps/cli/plug/__init__.py index a4b78ade4..4b59b97f5 100644 --- a/gramps/cli/plug/__init__.py +++ b/gramps/cli/plug/__init__.py @@ -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, diff --git a/gramps/gen/plug/docgen/paperstyle.py b/gramps/gen/plug/docgen/paperstyle.py index a3be6e07f..79809bf32 100644 --- a/gramps/gen/plug/docgen/paperstyle.py +++ b/gramps/gen/plug/docgen/paperstyle.py @@ -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" diff --git a/gramps/gen/plug/report/_paper.py b/gramps/gen/plug/report/_paper.py index 0cd235c37..c99c6bd89 100644 --- a/gramps/gen/plug/report/_paper.py +++ b/gramps/gen/plug/report/_paper.py @@ -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 ] diff --git a/gramps/gui/plug/report/_papermenu.py b/gramps/gui/plug/report/_papermenu.py index c45ddd200..ecde7b069 100644 --- a/gramps/gui/plug/report/_papermenu.py +++ b/gramps/gui/plug/report/_papermenu.py @@ -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(",", ".") )) diff --git a/po/POTFILES.in b/po/POTFILES.in index 0d6e7215a..f6855438b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -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 diff --git a/po/POTFILES.skip b/po/POTFILES.skip index de9017ac4..fc1957df0 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -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