Merge lp:~nataliabidart/ubuntuone-control-panel/unicode-gettext into lp:ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 264
Merged at revision: 263
Proposed branch: lp:~nataliabidart/ubuntuone-control-panel/unicode-gettext
Merge into: lp:ubuntuone-control-panel
Diff against target: 148 lines (+8/-50)
4 files modified
bin/ubuntuone-control-panel-gtk (+0/-5)
bin/ubuntuone-control-panel-qt (+1/-8)
setup.py (+0/-35)
ubuntuone/controlpanel/gui/__init__.py (+7/-2)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-control-panel/unicode-gettext
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Roman Yepishev (community) fieldtest Approve
Review via email: mp+94136@code.launchpad.net

Commit message

- Make gettext return unicode so we can format strings
  with unicode variables (LP: #937809).

To post a comment you must log in.
Revision history for this message
Roman Yepishev (rye) wrote :

Tested with spanish an russian locales - works properly.

review: Approve (fieldtest)
Revision history for this message
Manuel de la Peña (mandel) wrote :

+1 for this.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntuone-control-panel-gtk'
2--- bin/ubuntuone-control-panel-gtk 2012-01-18 14:09:16 +0000
3+++ bin/ubuntuone-control-panel-gtk 2012-02-22 12:15:22 +0000
4@@ -21,15 +21,10 @@
5
6 # Invalid name "ubuntuone-control-panel-gtk", pylint: disable=C0103
7
8-import gettext
9 import sys
10
11 from optparse import OptionParser
12
13-from ubuntuone.controlpanel import TRANSLATION_DOMAIN
14-
15-gettext.textdomain(TRANSLATION_DOMAIN)
16-# import the GUI after the translation domain has been set
17 from ubuntuone.controlpanel.gui.gtk import main
18
19
20
21=== modified file 'bin/ubuntuone-control-panel-qt'
22--- bin/ubuntuone-control-panel-qt 2012-01-18 14:09:16 +0000
23+++ bin/ubuntuone-control-panel-qt 2012-02-22 12:15:22 +0000
24@@ -1,8 +1,5 @@
25 #!/usr/bin/python
26 # -*- coding: utf-8 -*-
27-
28-# Authors: Natalia B Bidart <natalia.bidart@canonical.com>
29-# Eric Casteleijn <eric.casteleijn@canonical.com>
30 #
31 # Copyright 2010 Canonical Ltd.
32 #
33@@ -17,19 +14,15 @@
34 #
35 # You should have received a copy of the GNU General Public License along
36 # with this program. If not, see <http://www.gnu.org/licenses/>.
37+
38 """Execute the graphical interface for the Ubuntu One control panel."""
39
40 # Invalid name "ubuntuone-control-panel-qt", pylint: disable=C0103
41
42-import gettext
43 import sys
44
45 from optparse import OptionParser
46
47-from ubuntuone.controlpanel import TRANSLATION_DOMAIN
48-
49-gettext.textdomain(TRANSLATION_DOMAIN)
50-# import the GUI after the translation domain has been set
51 from ubuntuone.controlpanel.gui.qt import main
52
53
54
55=== modified file 'setup.py'
56--- setup.py 2012-02-10 17:10:56 +0000
57+++ setup.py 2012-02-22 12:15:22 +0000
58@@ -160,7 +160,6 @@
59
60 def run(self):
61 """Execute the command."""
62- self._wrapuic()
63 basepath = os.path.join('data', 'qt')
64 # TODO: build the resource files so that we can include them
65 #self.build_rc(os.path.join(basepath, 'icons_rc.py'),
66@@ -175,40 +174,6 @@
67
68 build_extra.build_extra.run(self)
69
70- # pylint: disable=E1002
71- _wrappeduic = False
72-
73- @classmethod
74- def _wrapuic(cls):
75- """Wrap uic to use gettext's _() in place of tr()"""
76- if cls._wrappeduic:
77- return
78-
79- from PyQt4.uic.Compiler import compiler, qtproxies, indenter
80-
81- # pylint: disable=C0103
82- class _UICompiler(compiler.UICompiler):
83- """Speciallized compiler for qt .ui files."""
84- def createToplevelWidget(self, classname, widgetname):
85- o = indenter.getIndenter()
86- o.level = 0
87- o.write('from gettext import gettext as _')
88- return super(_UICompiler, self).createToplevelWidget(classname,
89- widgetname)
90- compiler.UICompiler = _UICompiler
91-
92- class _i18n_string(qtproxies.i18n_string):
93- """Provide a translated text."""
94-
95- def __str__(self):
96- return "_('%s')" % self.string.encode('string-escape')
97-
98- qtproxies.i18n_string = _i18n_string
99-
100- cls._wrappeduic = True
101- # pylint: enable=C0103
102- # pylint: enable=E1002
103-
104
105 class ControlPanelClean(DistUtilsExtra.auto.clean_build_tree):
106 """Class to clean up after the build."""
107
108=== modified file 'ubuntuone/controlpanel/gui/__init__.py'
109--- ubuntuone/controlpanel/gui/__init__.py 2012-02-17 16:03:00 +0000
110+++ ubuntuone/controlpanel/gui/__init__.py 2012-02-22 12:15:22 +0000
111@@ -1,5 +1,5 @@
112 # -*- coding: utf-8 -*-
113-
114+#
115 # Copyright 2011-2012 Canonical Ltd.
116 #
117 # This program is free software: you can redistribute it and/or modify it
118@@ -18,10 +18,11 @@
119
120 import gettext
121
122+from ubuntuone.controlpanel import TRANSLATION_DOMAIN
123 from ubuntuone.controlpanel.backend import UBUNTUONE_LINK
124
125
126-_ = gettext.gettext
127+gettext.install(TRANSLATION_DOMAIN, unicode=True)
128
129
130 ERROR_COLOR = u'red'
131@@ -72,6 +73,8 @@
132 RESET_PASSWORD_LINK = EDIT_PROFILE_LINK + u'+forgot_password'
133 TWITTER_LINK = u'http://twitter.com/ubuntuone/'
134
135+# Undefined variable '_', pylint: disable=E0602
136+
137 ALWAYS_SUBSCRIBED = _('Always in sync')
138 CONNECT_BUTTON_LABEL = _('Connect to Ubuntu One')
139 CONTACTS = _('Thunderbird plug-in')
140@@ -168,6 +171,8 @@
141 VALUE_ERROR = _('Value could not be retrieved.')
142 UNKNOWN_ERROR = _('Unknown error')
143
144+# pylint: enable=E0602
145+
146
147 def humanize(int_bytes):
148 """Return a human readable representation of 'int_bytes'.

Subscribers

People subscribed via source and target branches