Merge lp:~dpm/ubuntu-sso-client/i18n into lp:ubuntu-sso-client

Proposed by David Planella
Status: Rejected
Rejected by: Natalia Bidart
Proposed branch: lp:~dpm/ubuntu-sso-client/i18n
Merge into: lp:ubuntu-sso-client
Diff against target: 293 lines (+74/-44)
6 files modified
bin/ubuntu-sso-login (+10/-11)
po/POTFILES.in (+5/-0)
setup.py (+9/-1)
ubuntu_sso/auth.py (+23/-11)
ubuntu_sso/gui.py (+7/-5)
ubuntu_sso/keyring.py (+20/-16)
To merge this branch: bzr merge lp:~dpm/ubuntu-sso-client/i18n
Reviewer Review Type Date Requested Status
David Planella (community) Disapprove
Ubuntu One hackers Pending
Review via email: mp+33107@code.launchpad.net

Description of the change

This merge proposal adds internationalization support to ubuntu-sso-client for bug 616515.

In order to do this I've adapted setup.py file to use python-distutils-extra to make use of its i18n commands. I've also added the gettext calls to relevant strings and added the po folder to contain translations.

I've checked that translatable strings are extracted correctly and a template is created with './setup.py build_i18n', but I'll leave further testing of the application and the build system to the Ubuntu One team. This patch should give you an idea of what is needed to implement i18n support.

A couple of notes:

* I've set the same translation domain in several places (see gettext.texdomain('ubuntu-sso-client')). I guess it would be best to define that in one single place, as we did with ubuntuone-client, but I'll leave this up to you.

* I guess the Ubuntu package will need a new dependency on python-distutils-extra

* I've noticed that there is an e-mail screenshot in the code. I'm not sure how this is used, but if it's shown in the UI, that's rather useless for users who don't speak English. Please consider using translatable text instead.

To post a comment you must log in.
Revision history for this message
David Planella (dpm) wrote :

After talking with Naty on IRC, she'll be working on this and include some of the changes in a next branch, as some of the files (e.g. auth.py) have now become obsolete very recently.

review: Disapprove

Unmerged revisions

578. By David Planella

Fixed the whitespace in some strings

577. By David Planella

Added i18n support and adapted setup.py for python-distutils-extra usage

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/ubuntu-sso-login'
2--- bin/ubuntu-sso-login 2010-08-05 21:12:57 +0000
3+++ bin/ubuntu-sso-login 2010-08-19 14:15:56 +0000
4@@ -25,6 +25,8 @@
5 import sys
6 import gettext
7 #from ubuntu import clientdefs
8+from gettext import gettext as _
9+gettext.textdomain('ubuntu-sso-client')
10
11 import dbus.service
12
13@@ -39,9 +41,6 @@
14 gtk.gdk.threads_init()
15 DBusGMainLoop(set_as_default=True)
16
17-_ = gettext.gettext
18-ngettext = gettext.ngettext
19-
20 OAUTH_REALM = "https://ubuntuone.com"
21 OAUTH_CONSUMER = "ubuntuone"
22
23@@ -181,8 +180,8 @@
24 from desktopcouch.records.server import CouchDatabase
25 except ImportError:
26 # desktopcouch is not installed
27- logger.debug(_("Not adding desktopcouch pairing since"
28- " desktopcouch is not installed"))
29+ logger.debug("Not adding desktopcouch pairing since"
30+ " desktopcouch is not installed")
31 return
32 # Check whether there is already a record of the Ubuntu One service
33 db = CouchDatabase("management", create=True)
34@@ -200,14 +199,14 @@
35 for row in results:
36 found = True
37 if row.value == 1:
38- logger.debug(_("Not adding desktopcouch pairing since"
39- " the user has explicitly unpaired with Ubuntu One"))
40+ logger.debug("Not adding desktopcouch pairing since"
41+ " the user has explicitly unpaired with Ubuntu One")
42 else:
43- logger.debug(_("Not adding desktopcouch pairing since"
44- " we are already paired"))
45+ logger.debug("Not adding desktopcouch pairing since"
46+ " we are already paired")
47 if not found:
48 put_static_paired_service(None, "ubuntuone")
49- logger.debug(_("Pairing desktopcouch with Ubuntu One"))
50+ logger.debug("Pairing desktopcouch with Ubuntu One")
51
52 def main(self):
53 """Starts the gtk main loop."""
54@@ -226,7 +225,7 @@
55 name = bus.request_name(DBUS_BUS_NAME,
56 dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
57 if name == dbus.bus.REQUEST_NAME_REPLY_EXISTS:
58- print _("Ubuntu One login manager already running, quitting")
59+ print "Ubuntu One login manager already running, quitting"
60 sys.exit(0)
61
62 from twisted.internet import gtk2reactor
63
64=== added directory 'po'
65=== added file 'po/POTFILES.in'
66--- po/POTFILES.in 1970-01-01 00:00:00 +0000
67+++ po/POTFILES.in 2010-08-19 14:15:56 +0000
68@@ -0,0 +1,5 @@
69+bin/ubuntu-sso-login
70+ubuntu_sso/auth.py
71+ubuntu_sso/keyring.py
72+ubuntu_sso/gui.py
73+[type: gettext/glade] data/ui.glade
74
75=== modified file 'setup.py'
76--- setup.py 2010-08-11 23:10:02 +0000
77+++ setup.py 2010-08-19 14:15:56 +0000
78@@ -19,6 +19,14 @@
79 import os
80 import sys
81
82+try:
83+ import DistUtilsExtra.auto
84+except ImportError:
85+ print >> sys.stderr, 'To build this program you need https://launchpad.net/python-distutils-extra'
86+ sys.exit(1)
87+assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18'
88+
89+
90 from distutils.core import setup
91 from distutils.spawn import find_executable
92 from distutils.command import clean, build
93@@ -70,7 +78,7 @@
94 clean.clean.run(self)
95
96
97-setup(
98+DistUtilsExtra.auto.setup(
99 name='ubuntu-sso-client',
100 version='0.99',
101 license='GPL v3',
102
103=== modified file 'ubuntu_sso/auth.py'
104--- ubuntu_sso/auth.py 2010-07-27 14:01:01 +0000
105+++ ubuntu_sso/auth.py 2010-08-19 14:15:56 +0000
106@@ -29,6 +29,9 @@
107 import subprocess
108 import socket, httplib, urllib
109 import sys
110+import gettext
111+from gettext import gettext as _
112+gettext.textdomain('ubuntu-sso-client')
113
114 import gnomekeyring
115 from oauth import oauth
116@@ -202,7 +205,7 @@
117 item_id = self.keyring.item_create_sync(
118 None,
119 gnomekeyring.ITEM_GENERIC_SECRET,
120- 'UbuntuOne token for %s' % self.realm,
121+ _('UbuntuOne token for %s') % self.realm,
122 {'ubuntuone-realm': self.realm,
123 'oauth-consumer-key': self.consumer.key},
124 access_token.to_string(),
125@@ -457,29 +460,38 @@
126 if nonce and (str(nonce) == str(self.nonce) and verifier):
127 self.retrieve_function(store=self.store_yes_no, verifier=verifier)
128 reactor.callLater(3, self.stop)
129- return """<!doctype html>
130+ return_desc = _('You should now automatically <a ' \
131+ 'href="%(url)s">return to %(url)s</a>.') % { 'url' : url }
132+ return_page = """<!doctype html>
133 <html><head><meta http-equiv="refresh"
134 content="0;url=%(url)s">
135 </head>
136 <body>
137- <p>You should now automatically <a
138- href="%(url)s">return to %(url)s</a>.</p>
139+ <p>%(return_desc)s</p>
140 </body>
141 </html>
142- """ % { 'url' : url }
143+ """ % { 'return_desc' : return_desc }
144+ return return_page
145 else:
146 self.retrieve_function(store=self.store_yes_no, verifier=verifier)
147 reactor.callLater(3, self.stop)
148 request.setResponseCode(400)
149- return """<!doctype html>
150- <html><head><title>Error</title></head>
151+
152+ error_title = _('Error')
153+ error_h1 = _('There was an error')
154+ error_desc = _('The authentication process has not succeeded.' \
155+ 'This may be a temporary problem; please try again in a few ' \
156+ 'minutes.')
157+ error_page = """<!doctype html>
158+ <html><head><title>%(error_title)s</title></head>
159 <body>
160- <h1>There was an error</h1>
161- <p>The authentication process has not succeeded. This may be a
162- temporary problem; please try again in a few minutes.</p>
163+ <h1>%(error_h1)</h1>
164+ <p>%(error_desc)s</p>
165 </body>
166 </html>
167- """
168+ """ % {'error_title': error_title, 'error_h1': error_h1, \
169+ 'error_desc': error_desc}
170+ return error_page
171
172
173
174
175=== modified file 'ubuntu_sso/gui.py'
176--- ubuntu_sso/gui.py 2010-08-11 22:44:19 +0000
177+++ ubuntu_sso/gui.py 2010-08-19 14:15:56 +0000
178@@ -38,7 +38,9 @@
179 from ubuntu_sso.logger import setupLogging
180
181
182-_ = gettext.gettext
183+from gettext import gettext as _
184+gettext.textdomain('ubuntu-sso-client')
185+
186 DBusGMainLoop(set_as_default=True)
187 logger = setupLogging('ubuntu_sso.gui')
188
189@@ -153,8 +155,8 @@
190 """Ubuntu single sign on GUI."""
191
192 CAPTCHA_SOLUTION_ENTRY = _('Type the characters above')
193- CONNECT_HELP_LABEL = _('To connect this computer to') + ' %s ' + \
194- _('enter your details below.')
195+ CONNECT_HELP_LABEL = _('To connect this computer to %s ' \
196+ 'enter your details below.')
197 EMAIL1_ENTRY = _('Email address')
198 EMAIL2_ENTRY = _('Re-type Email address')
199 EMAIL_MISMATCH = _('The email addresses don\'t match, please double check '
200@@ -163,11 +165,11 @@
201 EMAIL_TOKEN_ENTRY = _('Enter code verification here')
202 FIELD_REQUIRED = _('This field is required.')
203 FORGOTTEN_PASSWORD_BUTTON = _('I\'ve forgotten my password')
204- JOIN_HEADER_LABEL = _('Create') + ' %s ' + _('account')
205+ JOIN_HEADER_LABEL = _('Create %s account')
206 LOADING = _('Loading...')
207 LOGIN_BUTTON_LABEL = _('Already have an account? Click here to sign in')
208 LOGIN_EMAIL_ENTRY = _('Email address')
209- LOGIN_HEADER_LABEL = _('Connect to') + ' %s'
210+ LOGIN_HEADER_LABEL = _('Connect to %s')
211 LOGIN_PASSWORD_ENTRY = _('Password')
212 NAME_ENTRY = _('Name')
213 NEXT = _('Next')
214
215=== modified file 'ubuntu_sso/keyring.py'
216--- ubuntu_sso/keyring.py 2010-08-17 20:44:39 +0000
217+++ ubuntu_sso/keyring.py 2010-08-19 14:15:56 +0000
218@@ -2,7 +2,7 @@
219 #
220 # Authors:
221 # Andrew Higginson
222-# Alejandro J. Cura <alecu@canonical.com>
223+# Alejandro J. Cura <alecu@canonical.com>
224 #
225 # This program is free software; you can redistribute it and/or modify it under
226 # the terms of the GNU General Public License as published by the Free Software
227@@ -22,6 +22,10 @@
228 from urllib import urlencode
229 from urlparse import parse_qsl
230
231+import gettext
232+from gettext import gettext as _
233+gettext.textdomain('ubuntu-sso-client')
234+
235 class Keyring(object):
236
237 KEYRING_NAME = "login"
238@@ -40,7 +44,7 @@
239 keyring_names = gnomekeyring.list_keyring_names_sync()
240 if not name in keyring_names:
241 gnomekeyring.create_sync(name)
242-
243+
244 def _get_item_id_from_name(self, sync, name):
245 """
246 Returns the ID for a named item
247@@ -76,9 +80,9 @@
248 # No need to delete the item if it already exists
249
250 # A set of attributes for this credentials
251- attr = {"key-type": "Ubuntu SSO credentials",
252- "token-name": cred["name"].encode("utf8")}
253-
254+ attr = {"key-type": _("Ubuntu SSO credentials"),
255+ "token-name": cred["name"].encode("utf8")}
256+
257 # Add our SSO credentials to the keyring
258 gnomekeyring.item_create_sync(self.KEYRING_NAME,
259 gnomekeyring.ITEM_GENERIC_SECRET, self.app_name, attr,
260@@ -95,23 +99,23 @@
261 secret = self._get_item_info_from_name(self.KEYRING_NAME,
262 self.app_name).get_secret()
263 return dict(parse_qsl(secret))
264-
265- def delete_ubuntusso_attr(self):
266- """
267- Delete a set of credentials from the keyring
268- """
269+
270+ def delete_ubuntusso_attr(self):
271+ """
272+ Delete a set of credentials from the keyring
273+ """
274 item_id = self._get_item_id_from_name(self.KEYRING_NAME,
275 self.app_name)
276- if item_id is not None:
277- gnomekeyring.item_delete_sync(self.KEYRING_NAME, item_id)
278+ if item_id is not None:
279+ gnomekeyring.item_delete_sync(self.KEYRING_NAME, item_id)
280
281 if __name__ == "__main__":
282 kr1 = Keyring("Test key 1")
283 kr2 = Keyring("Test key 2")
284-
285- kr1.delete_ubuntusso_attr()
286- kr2.delete_ubuntusso_attr()
287-
288+
289+ kr1.delete_ubuntusso_attr()
290+ kr2.delete_ubuntusso_attr()
291+
292 d1 = {"name":"test-1", "ha":"hehddddeff", "hi":"hggehes", "ho":"he"}
293 d2 = {"name":"test-2", "hi":"ho", "let's":"go"}
294

Subscribers

People subscribed via source and target branches