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
=== modified file 'bin/ubuntu-sso-login'
--- bin/ubuntu-sso-login 2010-08-05 21:12:57 +0000
+++ bin/ubuntu-sso-login 2010-08-19 14:15:56 +0000
@@ -25,6 +25,8 @@
25import sys25import sys
26import gettext26import gettext
27#from ubuntu import clientdefs27#from ubuntu import clientdefs
28from gettext import gettext as _
29gettext.textdomain('ubuntu-sso-client')
2830
29import dbus.service31import dbus.service
3032
@@ -39,9 +41,6 @@
39gtk.gdk.threads_init()41gtk.gdk.threads_init()
40DBusGMainLoop(set_as_default=True)42DBusGMainLoop(set_as_default=True)
4143
42_ = gettext.gettext
43ngettext = gettext.ngettext
44
45OAUTH_REALM = "https://ubuntuone.com"44OAUTH_REALM = "https://ubuntuone.com"
46OAUTH_CONSUMER = "ubuntuone"45OAUTH_CONSUMER = "ubuntuone"
4746
@@ -181,8 +180,8 @@
181 from desktopcouch.records.server import CouchDatabase180 from desktopcouch.records.server import CouchDatabase
182 except ImportError:181 except ImportError:
183 # desktopcouch is not installed182 # desktopcouch is not installed
184 logger.debug(_("Not adding desktopcouch pairing since"183 logger.debug("Not adding desktopcouch pairing since"
185 " desktopcouch is not installed"))184 " desktopcouch is not installed")
186 return185 return
187 # Check whether there is already a record of the Ubuntu One service186 # Check whether there is already a record of the Ubuntu One service
188 db = CouchDatabase("management", create=True)187 db = CouchDatabase("management", create=True)
@@ -200,14 +199,14 @@
200 for row in results:199 for row in results:
201 found = True200 found = True
202 if row.value == 1:201 if row.value == 1:
203 logger.debug(_("Not adding desktopcouch pairing since"202 logger.debug("Not adding desktopcouch pairing since"
204 " the user has explicitly unpaired with Ubuntu One"))203 " the user has explicitly unpaired with Ubuntu One")
205 else:204 else:
206 logger.debug(_("Not adding desktopcouch pairing since"205 logger.debug("Not adding desktopcouch pairing since"
207 " we are already paired"))206 " we are already paired")
208 if not found:207 if not found:
209 put_static_paired_service(None, "ubuntuone")208 put_static_paired_service(None, "ubuntuone")
210 logger.debug(_("Pairing desktopcouch with Ubuntu One"))209 logger.debug("Pairing desktopcouch with Ubuntu One")
211210
212 def main(self):211 def main(self):
213 """Starts the gtk main loop."""212 """Starts the gtk main loop."""
@@ -226,7 +225,7 @@
226 name = bus.request_name(DBUS_BUS_NAME,225 name = bus.request_name(DBUS_BUS_NAME,
227 dbus.bus.NAME_FLAG_DO_NOT_QUEUE)226 dbus.bus.NAME_FLAG_DO_NOT_QUEUE)
228 if name == dbus.bus.REQUEST_NAME_REPLY_EXISTS:227 if name == dbus.bus.REQUEST_NAME_REPLY_EXISTS:
229 print _("Ubuntu One login manager already running, quitting")228 print "Ubuntu One login manager already running, quitting"
230 sys.exit(0)229 sys.exit(0)
231230
232 from twisted.internet import gtk2reactor231 from twisted.internet import gtk2reactor
233232
=== added directory 'po'
=== added file 'po/POTFILES.in'
--- po/POTFILES.in 1970-01-01 00:00:00 +0000
+++ po/POTFILES.in 2010-08-19 14:15:56 +0000
@@ -0,0 +1,5 @@
1bin/ubuntu-sso-login
2ubuntu_sso/auth.py
3ubuntu_sso/keyring.py
4ubuntu_sso/gui.py
5[type: gettext/glade] data/ui.glade
06
=== modified file 'setup.py'
--- setup.py 2010-08-11 23:10:02 +0000
+++ setup.py 2010-08-19 14:15:56 +0000
@@ -19,6 +19,14 @@
19import os19import os
20import sys20import sys
2121
22try:
23 import DistUtilsExtra.auto
24except ImportError:
25 print >> sys.stderr, 'To build this program you need https://launchpad.net/python-distutils-extra'
26 sys.exit(1)
27assert DistUtilsExtra.auto.__version__ >= '2.18', 'needs DistUtilsExtra.auto >= 2.18'
28
29
22from distutils.core import setup30from distutils.core import setup
23from distutils.spawn import find_executable31from distutils.spawn import find_executable
24from distutils.command import clean, build32from distutils.command import clean, build
@@ -70,7 +78,7 @@
70 clean.clean.run(self)78 clean.clean.run(self)
7179
7280
73setup(81DistUtilsExtra.auto.setup(
74 name='ubuntu-sso-client',82 name='ubuntu-sso-client',
75 version='0.99',83 version='0.99',
76 license='GPL v3',84 license='GPL v3',
7785
=== modified file 'ubuntu_sso/auth.py'
--- ubuntu_sso/auth.py 2010-07-27 14:01:01 +0000
+++ ubuntu_sso/auth.py 2010-08-19 14:15:56 +0000
@@ -29,6 +29,9 @@
29import subprocess29import subprocess
30import socket, httplib, urllib30import socket, httplib, urllib
31import sys31import sys
32import gettext
33from gettext import gettext as _
34gettext.textdomain('ubuntu-sso-client')
3235
33import gnomekeyring36import gnomekeyring
34from oauth import oauth37from oauth import oauth
@@ -202,7 +205,7 @@
202 item_id = self.keyring.item_create_sync(205 item_id = self.keyring.item_create_sync(
203 None,206 None,
204 gnomekeyring.ITEM_GENERIC_SECRET,207 gnomekeyring.ITEM_GENERIC_SECRET,
205 'UbuntuOne token for %s' % self.realm,208 _('UbuntuOne token for %s') % self.realm,
206 {'ubuntuone-realm': self.realm,209 {'ubuntuone-realm': self.realm,
207 'oauth-consumer-key': self.consumer.key},210 'oauth-consumer-key': self.consumer.key},
208 access_token.to_string(),211 access_token.to_string(),
@@ -457,29 +460,38 @@
457 if nonce and (str(nonce) == str(self.nonce) and verifier):460 if nonce and (str(nonce) == str(self.nonce) and verifier):
458 self.retrieve_function(store=self.store_yes_no, verifier=verifier)461 self.retrieve_function(store=self.store_yes_no, verifier=verifier)
459 reactor.callLater(3, self.stop)462 reactor.callLater(3, self.stop)
460 return """<!doctype html>463 return_desc = _('You should now automatically <a ' \
464 'href="%(url)s">return to %(url)s</a>.') % { 'url' : url }
465 return_page = """<!doctype html>
461 <html><head><meta http-equiv="refresh"466 <html><head><meta http-equiv="refresh"
462 content="0;url=%(url)s">467 content="0;url=%(url)s">
463 </head>468 </head>
464 <body>469 <body>
465 <p>You should now automatically <a470 <p>%(return_desc)s</p>
466 href="%(url)s">return to %(url)s</a>.</p>
467 </body>471 </body>
468 </html>472 </html>
469 """ % { 'url' : url }473 """ % { 'return_desc' : return_desc }
474 return return_page
470 else:475 else:
471 self.retrieve_function(store=self.store_yes_no, verifier=verifier)476 self.retrieve_function(store=self.store_yes_no, verifier=verifier)
472 reactor.callLater(3, self.stop)477 reactor.callLater(3, self.stop)
473 request.setResponseCode(400)478 request.setResponseCode(400)
474 return """<!doctype html>479
475 <html><head><title>Error</title></head>480 error_title = _('Error')
481 error_h1 = _('There was an error')
482 error_desc = _('The authentication process has not succeeded.' \
483 'This may be a temporary problem; please try again in a few ' \
484 'minutes.')
485 error_page = """<!doctype html>
486 <html><head><title>%(error_title)s</title></head>
476 <body>487 <body>
477 <h1>There was an error</h1>488 <h1>%(error_h1)</h1>
478 <p>The authentication process has not succeeded. This may be a489 <p>%(error_desc)s</p>
479 temporary problem; please try again in a few minutes.</p>
480 </body>490 </body>
481 </html>491 </html>
482 """492 """ % {'error_title': error_title, 'error_h1': error_h1, \
493 'error_desc': error_desc}
494 return error_page
483495
484496
485497
486498
=== modified file 'ubuntu_sso/gui.py'
--- ubuntu_sso/gui.py 2010-08-11 22:44:19 +0000
+++ ubuntu_sso/gui.py 2010-08-19 14:15:56 +0000
@@ -38,7 +38,9 @@
38from ubuntu_sso.logger import setupLogging38from ubuntu_sso.logger import setupLogging
3939
4040
41_ = gettext.gettext41from gettext import gettext as _
42gettext.textdomain('ubuntu-sso-client')
43
42DBusGMainLoop(set_as_default=True)44DBusGMainLoop(set_as_default=True)
43logger = setupLogging('ubuntu_sso.gui')45logger = setupLogging('ubuntu_sso.gui')
4446
@@ -153,8 +155,8 @@
153 """Ubuntu single sign on GUI."""155 """Ubuntu single sign on GUI."""
154156
155 CAPTCHA_SOLUTION_ENTRY = _('Type the characters above')157 CAPTCHA_SOLUTION_ENTRY = _('Type the characters above')
156 CONNECT_HELP_LABEL = _('To connect this computer to') + ' %s ' + \158 CONNECT_HELP_LABEL = _('To connect this computer to %s ' \
157 _('enter your details below.')159 'enter your details below.')
158 EMAIL1_ENTRY = _('Email address')160 EMAIL1_ENTRY = _('Email address')
159 EMAIL2_ENTRY = _('Re-type Email address')161 EMAIL2_ENTRY = _('Re-type Email address')
160 EMAIL_MISMATCH = _('The email addresses don\'t match, please double check '162 EMAIL_MISMATCH = _('The email addresses don\'t match, please double check '
@@ -163,11 +165,11 @@
163 EMAIL_TOKEN_ENTRY = _('Enter code verification here')165 EMAIL_TOKEN_ENTRY = _('Enter code verification here')
164 FIELD_REQUIRED = _('This field is required.')166 FIELD_REQUIRED = _('This field is required.')
165 FORGOTTEN_PASSWORD_BUTTON = _('I\'ve forgotten my password')167 FORGOTTEN_PASSWORD_BUTTON = _('I\'ve forgotten my password')
166 JOIN_HEADER_LABEL = _('Create') + ' %s ' + _('account')168 JOIN_HEADER_LABEL = _('Create %s account')
167 LOADING = _('Loading...')169 LOADING = _('Loading...')
168 LOGIN_BUTTON_LABEL = _('Already have an account? Click here to sign in')170 LOGIN_BUTTON_LABEL = _('Already have an account? Click here to sign in')
169 LOGIN_EMAIL_ENTRY = _('Email address')171 LOGIN_EMAIL_ENTRY = _('Email address')
170 LOGIN_HEADER_LABEL = _('Connect to') + ' %s'172 LOGIN_HEADER_LABEL = _('Connect to %s')
171 LOGIN_PASSWORD_ENTRY = _('Password')173 LOGIN_PASSWORD_ENTRY = _('Password')
172 NAME_ENTRY = _('Name')174 NAME_ENTRY = _('Name')
173 NEXT = _('Next')175 NEXT = _('Next')
174176
=== modified file 'ubuntu_sso/keyring.py'
--- ubuntu_sso/keyring.py 2010-08-17 20:44:39 +0000
+++ ubuntu_sso/keyring.py 2010-08-19 14:15:56 +0000
@@ -2,7 +2,7 @@
2#2#
3# Authors:3# Authors:
4# Andrew Higginson4# Andrew Higginson
5# Alejandro J. Cura <alecu@canonical.com>5# Alejandro J. Cura <alecu@canonical.com>
6#6#
7# This program is free software; you can redistribute it and/or modify it under7# This program is free software; you can redistribute it and/or modify it under
8# the terms of the GNU General Public License as published by the Free Software8# the terms of the GNU General Public License as published by the Free Software
@@ -22,6 +22,10 @@
22from urllib import urlencode22from urllib import urlencode
23from urlparse import parse_qsl23from urlparse import parse_qsl
2424
25import gettext
26from gettext import gettext as _
27gettext.textdomain('ubuntu-sso-client')
28
25class Keyring(object):29class Keyring(object):
2630
27 KEYRING_NAME = "login"31 KEYRING_NAME = "login"
@@ -40,7 +44,7 @@
40 keyring_names = gnomekeyring.list_keyring_names_sync()44 keyring_names = gnomekeyring.list_keyring_names_sync()
41 if not name in keyring_names:45 if not name in keyring_names:
42 gnomekeyring.create_sync(name)46 gnomekeyring.create_sync(name)
4347
44 def _get_item_id_from_name(self, sync, name):48 def _get_item_id_from_name(self, sync, name):
45 """49 """
46 Returns the ID for a named item50 Returns the ID for a named item
@@ -76,9 +80,9 @@
76 # No need to delete the item if it already exists80 # No need to delete the item if it already exists
7781
78 # A set of attributes for this credentials82 # A set of attributes for this credentials
79 attr = {"key-type": "Ubuntu SSO credentials",83 attr = {"key-type": _("Ubuntu SSO credentials"),
80 "token-name": cred["name"].encode("utf8")}84 "token-name": cred["name"].encode("utf8")}
8185
82 # Add our SSO credentials to the keyring86 # Add our SSO credentials to the keyring
83 gnomekeyring.item_create_sync(self.KEYRING_NAME,87 gnomekeyring.item_create_sync(self.KEYRING_NAME,
84 gnomekeyring.ITEM_GENERIC_SECRET, self.app_name, attr,88 gnomekeyring.ITEM_GENERIC_SECRET, self.app_name, attr,
@@ -95,23 +99,23 @@
95 secret = self._get_item_info_from_name(self.KEYRING_NAME,99 secret = self._get_item_info_from_name(self.KEYRING_NAME,
96 self.app_name).get_secret()100 self.app_name).get_secret()
97 return dict(parse_qsl(secret))101 return dict(parse_qsl(secret))
98102
99 def delete_ubuntusso_attr(self):103 def delete_ubuntusso_attr(self):
100 """104 """
101 Delete a set of credentials from the keyring105 Delete a set of credentials from the keyring
102 """106 """
103 item_id = self._get_item_id_from_name(self.KEYRING_NAME,107 item_id = self._get_item_id_from_name(self.KEYRING_NAME,
104 self.app_name)108 self.app_name)
105 if item_id is not None:109 if item_id is not None:
106 gnomekeyring.item_delete_sync(self.KEYRING_NAME, item_id)110 gnomekeyring.item_delete_sync(self.KEYRING_NAME, item_id)
107111
108if __name__ == "__main__":112if __name__ == "__main__":
109 kr1 = Keyring("Test key 1")113 kr1 = Keyring("Test key 1")
110 kr2 = Keyring("Test key 2")114 kr2 = Keyring("Test key 2")
111115
112 kr1.delete_ubuntusso_attr()116 kr1.delete_ubuntusso_attr()
113 kr2.delete_ubuntusso_attr()117 kr2.delete_ubuntusso_attr()
114118
115 d1 = {"name":"test-1", "ha":"hehddddeff", "hi":"hggehes", "ho":"he"}119 d1 = {"name":"test-1", "ha":"hehddddeff", "hi":"hggehes", "ho":"he"}
116 d2 = {"name":"test-2", "hi":"ho", "let's":"go"}120 d2 = {"name":"test-2", "hi":"ho", "let's":"go"}
117121

Subscribers

People subscribed via source and target branches