From 150f5b84836a2c4e4e3c7c1f69a60b69434fc892 Mon Sep 17 00:00:00 2001
Message-Id: <150f5b84836a2c4e4e3c7c1f69a60b69434fc892.1337098744.git.humitos@gmail.com>
From: Manuel Kaufmann <humitos@gmail.com>
Date: Tue, 15 May 2012 13:18:57 -0300
Subject: [PATCH Distance] Units apply l10n SL #3524
When the string is not going to be used when it's declarated we should
do a workaround[1] to use the translated version later.
[1] http://docs.python.org/library/gettext.html#deferred-translations
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
---
smoot_toolbar.py | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/smoot_toolbar.py b/smoot_toolbar.py
index 334fd76..f0a49d6 100644
a
|
b
|
|
16 | 16 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
17 | 17 | |
18 | 18 | import gtk |
19 | | from gettext import gettext as _ |
20 | 19 | |
21 | 20 | from sugar.graphics.combobox import ComboBox |
22 | 21 | from sugar.graphics.toolcombobox import ToolComboBox |
… |
… |
INCHES = 2 |
27 | 26 | FEET = 3 |
28 | 27 | YARDS = 4 |
29 | 28 | CUSTOM = 5 |
| 29 | |
| 30 | |
| 31 | # This is a workaround to fix SL #3524 |
| 32 | # Documentation: |
| 33 | # http://docs.python.org/library/gettext.html#deferred-translations |
| 34 | def _(message): |
| 35 | return message |
| 36 | |
30 | 37 | UNITS = [_('meters'), _('centimeters'), |
31 | 38 | # TRANS: English units of measure |
32 | 39 | _('inches'), _('feet'), _('yards'), |
… |
… |
UNIT_DICTIONARY = {METERS: (_('meters'), 1.0), |
37 | 44 | FEET: (_('feet'), 3.28), |
38 | 45 | YARDS: (_('yards'), 1.09), |
39 | 46 | CUSTOM: (_('custom units'), None)} |
| 47 | del _ |
| 48 | from gettext import gettext as _ |
40 | 49 | |
41 | 50 | |
42 | 51 | def _label_factory(label, toolbar): |
… |
… |
def _combo_factory(combo_array, default, tooltip, toolbar): |
58 | 67 | my_combo.set_tooltip_text(tooltip) |
59 | 68 | |
60 | 69 | for i, s in enumerate(combo_array): |
61 | | my_combo.append_item(i, s, None) |
| 70 | my_combo.append_item(i, _(s), None) |
62 | 71 | |
63 | 72 | toolbar.insert(ToolComboBox(my_combo), -1) |
64 | 73 | |
… |
… |
class SmootToolbar(gtk.Toolbar): |
96 | 105 | self._unit_name = name |
97 | 106 | if hasattr(self._parent, 'fr'): |
98 | 107 | self._parent.fr.set_label( |
99 | | _('Measured distance in %s') % (self._unit_name)) |
| 108 | _('Measured distance in %s') % _(self._unit_name)) |
100 | 109 | if name == _('meters'): |
101 | 110 | self._factor_label.set_label(' ') |
102 | 111 | else: |
103 | 112 | self._factor_label.set_label(_('%(unit)20.2f %(name)s per meter') % |
104 | | {'unit': self._unit_scale, 'name': name}) |
| 113 | {'unit': self._unit_scale, 'name': _(name)}) |
105 | 114 | |
106 | 115 | def get_scale(self): |
107 | 116 | return self._unit_scale |