Merge lp:~thisfred/ubuntuone-client/fix-lp-723327 into lp:ubuntuone-client

Proposed by Eric Casteleijn on 2011-02-23
Status: Merged
Approved by: Eric Casteleijn on 2011-02-24
Approved revision: 890
Merged at revision: 892
Proposed branch: lp:~thisfred/ubuntuone-client/fix-lp-723327
Merge into: lp:ubuntuone-client
Diff against target: 286 lines (+96/-75)
2 files modified
tests/status/test_aggregator.py (+27/-42)
ubuntuone/status/aggregator.py (+69/-33)
To merge this branch: bzr merge lp:~thisfred/ubuntuone-client/fix-lp-723327
Reviewer Review Type Date Requested Status
Natalia Bidart Approve on 2011-02-24
Alejandro J. Cura (community) 2011-02-23 Approve on 2011-02-24
Review via email: mp+51009@code.launchpad.net

Commit message

Correctly fixes singular/plural i18n.

Description of the change

Correctly fixes singular/plural i18n.

To post a comment you must log in.
Alejandro J. Cura (alecu) wrote :

Much better!

review: Approve
Natalia Bidart (nataliabidart) wrote :

(11:38:45 AM) nessita: thisfred: the string
(11:38:45 AM) nessita: 111+FILES_UPLOADING_M = (
(11:38:45 AM) nessita: 112+ "%(total_uploading_files)d files are being uploaded to your personal"
(11:38:45 AM) nessita: 113+ " cloud.")
(11:38:45 AM) nessita: is not in the ubuntuone-client.pot file

in fact,

nessita@dali:~/canonical/u1/client/review_fix-lp-723327/po$ grep "files are being uploaded to your personal" *
nessita@dali:~/canonical/u1/client/review_fix-lp-723327/po$

review: Needs Fixing
Eric Casteleijn (thisfred) wrote :

Fixed in r889

889. By Eric Casteleijn on 2011-02-24

fixed i18n so that the strings get properly extracted

890. By Eric Casteleijn on 2011-02-24

removed unused format_args

Natalia Bidart (nataliabidart) wrote :

Now all strings seems to be in place for translations.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/status/test_aggregator.py'
2--- tests/status/test_aggregator.py 2011-02-23 00:53:28 +0000
3+++ tests/status/test_aggregator.py 2011-02-24 15:57:48 +0000
4@@ -1335,12 +1335,10 @@
5 """Test the message that's shown on the discovery bubble."""
6 uploading = 10
7 downloading = 8
8- upload_fmt = {"total_uploading_files": uploading}
9- download_fmt = {"total_downloading_files": downloading}
10 self.aggregator.files_uploading.extend(range(uploading))
11 self.aggregator.files_downloading.extend(range(downloading))
12- expected = (aggregator.FILES_UPLOADING % upload_fmt + "\n" +
13- aggregator.FILES_DOWNLOADING % download_fmt)
14+ expected = (aggregator.files_being_uploaded(uploading) +
15+ "\n" + aggregator.files_being_downloaded(downloading))
16 result = self.aggregator.get_discovery_message()
17 self.assertEqual(expected, result)
18
19@@ -1355,14 +1353,14 @@
20 percentage = int(100.0 * self.aggregator.done_counter /
21 self.aggregator.total_counter)
22 format_args = {
23- "total_uploading_files": self.aggregator.upload_total,
24- "total_downloading_files": self.aggregator.download_total,
25 "percentage_completed": percentage,
26 }
27
28- format_string = (aggregator.FILES_UPLOADING + "\n" +
29- aggregator.FILES_DOWNLOADING + "\n" +
30- aggregator.PROGRESS_COMPLETED)
31+ format_string = (
32+ aggregator.files_being_uploaded(self.aggregator.upload_total) +
33+ "\n" +
34+ aggregator.files_being_downloaded(self.aggregator.download_total) +
35+ "\n" + aggregator.PROGRESS_COMPLETED)
36
37 expected = format_string % format_args
38 result = self.aggregator.get_progress_message()
39@@ -1379,12 +1377,11 @@
40 percentage = int(100.0 * self.aggregator.done_counter /
41 self.aggregator.total_counter)
42 format_args = {
43- "total_downloading_files": self.aggregator.download_total,
44- "percentage_completed": percentage,
45- }
46+ "percentage_completed": percentage}
47
48- format_string = (aggregator.FILES_DOWNLOADING + "\n" +
49- aggregator.PROGRESS_COMPLETED)
50+ format_string = (
51+ aggregator.files_being_downloaded(self.aggregator.download_total) +
52+ "\n" + aggregator.PROGRESS_COMPLETED)
53
54 expected = format_string % format_args
55 result = self.aggregator.get_progress_message()
56@@ -1401,12 +1398,12 @@
57 percentage = int(100.0 * self.aggregator.done_counter /
58 self.aggregator.total_counter)
59 format_args = {
60- "total_uploading_files": self.aggregator.upload_total,
61 "percentage_completed": percentage,
62 }
63
64- format_string = (aggregator.FILES_UPLOADING + "\n" +
65- aggregator.PROGRESS_COMPLETED)
66+ format_string = (
67+ aggregator.files_being_uploaded(self.aggregator.upload_total) +
68+ "\n" + aggregator.PROGRESS_COMPLETED)
69
70 expected = format_string % format_args
71 result = self.aggregator.get_progress_message()
72@@ -1422,50 +1419,38 @@
73 done = (5, 10)
74 self.aggregator.upload_done, self.aggregator.download_done = done
75
76- format_args = {
77- "total_uploaded_files": self.aggregator.upload_done,
78- "total_downloaded_files": self.aggregator.download_done,
79- }
80-
81- format_string = (aggregator.FINAL_COMPLETED + "\n" +
82- aggregator.FINAL_UPLOADED + "\n" +
83- aggregator.FINAL_DOWNLOADED)
84-
85- expected = format_string % format_args
86+ format_string = (
87+ aggregator.FINAL_COMPLETED + "\n" +
88+ aggregator.files_were_uploaded(self.aggregator.upload_done) +
89+ "\n" +
90+ aggregator.files_were_downloaded(self.aggregator.download_done))
91+
92 result = self.aggregator.get_final_status_message()
93- self.assertEqual(expected, result)
94+ self.assertEqual(format_string, result)
95
96 def test_get_final_status_message_no_uploads(self):
97 """The final status message when there were no uploads."""
98 done = (0, 12)
99 self.aggregator.upload_done, self.aggregator.download_done = done
100
101- format_args = {
102- "total_downloaded_files": self.aggregator.download_done,
103- }
104-
105 format_string = (aggregator.FINAL_COMPLETED + "\n" +
106- aggregator.FINAL_DOWNLOADED)
107+ aggregator.files_were_downloaded(
108+ self.aggregator.download_done))
109
110- expected = format_string % format_args
111 result = self.aggregator.get_final_status_message()
112- self.assertEqual(expected, result)
113+ self.assertEqual(format_string, result)
114
115 def test_get_final_status_message_no_downloads(self):
116 """The final status message when there were no downloads."""
117 done = (8, 0)
118 self.aggregator.upload_done, self.aggregator.download_done = done
119
120- format_args = {
121- "total_uploaded_files": self.aggregator.upload_done,
122- }
123-
124 format_string = (aggregator.FINAL_COMPLETED + "\n" +
125- aggregator.FINAL_UPLOADED)
126+ aggregator.files_were_uploaded(
127+ self.aggregator.upload_done))
128
129- expected = format_string % format_args
130 result = self.aggregator.get_final_status_message()
131- self.assertEqual(expected, result)
132+ self.assertEqual(format_string, result)
133
134 def test_started_progress_bubble(self):
135 """The progress bubble is started."""
136
137=== modified file 'ubuntuone/status/aggregator.py'
138--- ubuntuone/status/aggregator.py 2011-02-23 23:43:17 +0000
139+++ ubuntuone/status/aggregator.py 2011-02-24 15:57:48 +0000
140@@ -34,6 +34,7 @@
141 from ubuntuone.platform.unity import UbuntuOneLauncher
142
143 Q_ = lambda string: gettext.dgettext(GETTEXT_PACKAGE, string)
144+
145 LOG_LEVEL = logging.DEBUG
146 logger = logging.getLogger('ubuntuone.status')
147 logger.setLevel(LOG_LEVEL)
148@@ -47,18 +48,57 @@
149 UBUNTUONE_TITLE = Q_("Ubuntu One")
150 NEW_UDFS_SENDER = Q_("New cloud folder(s) available")
151 FINAL_COMPLETED = Q_("File synchronization completed.")
152-FINAL_UPLOADED = Q_("%(total_uploaded_files)d file(s) were uploaded to " +
153- "your personal cloud.")
154-FINAL_DOWNLOADED = Q_("%(total_downloaded_files)d file(s) were downloaded " +
155- "to your computer.")
156-FILES_UPLOADING = Q_("%(total_uploading_files)d file(s) are uploading to " +
157- "your personal cloud.")
158-FILES_DOWNLOADING = Q_("%(total_downloading_files)d file(s) are downloading " +
159- "to your computer.")
160+
161 PROGRESS_COMPLETED = Q_("%(percentage_completed)d%% completed.")
162 FILE_SYNC_IN_PROGRESS = Q_("File synchronization in progress")
163
164
165+def files_being_uploaded(files_uploading):
166+ """Get the i18n string for files being uploaded."""
167+ format_args = {"total_uploading_files": files_uploading}
168+ return gettext.dngettext(
169+ GETTEXT_PACKAGE,
170+ "%(total_uploading_files)d file is being uploaded to your personal "
171+ "cloud.",
172+ "%(total_uploading_files)d files are being uploaded to your personal "
173+ "cloud.",
174+ files_uploading) % format_args
175+
176+
177+def files_being_downloaded(files_downloading):
178+ """Get the i18n string for files being downloaded."""
179+ format_args = {"total_downloading_files": files_downloading}
180+ return gettext.dngettext(
181+ GETTEXT_PACKAGE,
182+ "%(total_downloading_files)d file is being downloaded to your "
183+ "computer.",
184+ "%(total_downloading_files)d files are being downloaded to "
185+ "your computer.",
186+ files_downloading) % format_args
187+
188+
189+def files_were_uploaded(upload_done):
190+ """Get the i18n string for files that were uploaded."""
191+ format_args = {'total_uploaded_files': upload_done}
192+ return gettext.dngettext(
193+ GETTEXT_PACKAGE,
194+ "%(total_uploaded_files)d file was uploaded to your personal "
195+ "cloud.",
196+ "%(total_uploaded_files)d files were uploaded to your "
197+ "personal cloud.", upload_done) % format_args
198+
199+
200+def files_were_downloaded(download_done):
201+ """Get the i18n string for files that were downloaded."""
202+ format_args = {'total_downloaded_files': download_done}
203+ return gettext.dngettext(
204+ GETTEXT_PACKAGE,
205+ "%(total_downloaded_files)d file was downloaded to your "
206+ "computer.",
207+ "%(total_downloaded_files)d files were downloaded to your "
208+ "computer.", download_done) % format_args
209+
210+
211 class ToggleableNotification(object):
212 """A controller for notifications that can be turned off."""
213
214@@ -179,7 +219,7 @@
215 """The connection to the server changed status."""
216
217 WEIGHT = 30
218- MESSAGE_MANY = "" # taken from the last one in the list
219+ MESSAGE_MANY = "" # taken from the last one in the list
220
221 def many(self, events):
222 """Only the last message if there are many events of this type."""
223@@ -584,30 +624,25 @@
224 def get_discovery_message(self):
225 """Get the text for the discovery bubble."""
226 lines = []
227-
228- if len(self.files_uploading) > 0:
229- format_args = {"total_uploading_files": len(self.files_uploading)}
230- text = FILES_UPLOADING % format_args
231- lines.append(text)
232-
233- if len(self.files_downloading) > 0:
234- num_files_downloading = len(self.files_downloading)
235- format_args = {"total_downloading_files": num_files_downloading}
236- text = FILES_DOWNLOADING % format_args
237- lines.append(text)
238-
239+ files_uploading = len(self.files_uploading)
240+ if files_uploading > 0:
241+ lines.append(files_being_uploaded(files_uploading))
242+
243+ files_downloading = len(self.files_downloading)
244+ if files_downloading > 0:
245+ lines.append(files_being_downloaded(files_downloading))
246 return "\n".join(lines)
247
248 def get_progress_message(self):
249 """Get some lines describing the progress."""
250 assert self.total_counter > 0
251 parts = []
252- if self.upload_total:
253- format_args = {"total_uploading_files": self.upload_total}
254- parts.append(FILES_UPLOADING % format_args)
255- if self.download_total:
256- format_args = {"total_downloading_files": self.download_total}
257- parts.append(FILES_DOWNLOADING % format_args)
258+ upload_total = self.upload_total
259+ if upload_total:
260+ parts.append(files_being_uploaded(upload_total))
261+ download_total = self.download_total
262+ if download_total:
263+ parts.append(files_being_downloaded(download_total))
264 progress_percentage = 100.0 * self.done_counter / self.total_counter
265 format_args = {"percentage_completed": int(progress_percentage)}
266 parts.append(PROGRESS_COMPLETED % format_args)
267@@ -617,12 +652,13 @@
268 """Get some lines describing all we did."""
269 parts = []
270 parts.append(FINAL_COMPLETED)
271- if self.upload_done:
272- format_args = {'total_uploaded_files': self.upload_done}
273- parts.append(FINAL_UPLOADED % format_args)
274- if self.download_done:
275- format_args = {'total_downloaded_files': self.download_done}
276- parts.append(FINAL_DOWNLOADED % format_args)
277+ upload_done = self.upload_done
278+ if upload_done:
279+ parts.append(files_were_uploaded(upload_done))
280+
281+ download_done = self.download_done
282+ if download_done:
283+ parts.append(files_were_downloaded(download_done))
284 return "\n".join(parts)
285
286 def restart_progress_bubble(self):

Subscribers

People subscribed via source and target branches