Merge lp:~adiroiban/launchpad/bug-561586 into lp:launchpad

Proposed by Adi Roiban
Status: Merged
Approved by: Edwin Grubbs
Approved revision: no longer in the source branch.
Merged at revision: 10898
Proposed branch: lp:~adiroiban/launchpad/bug-561586
Merge into: lp:launchpad
Diff against target: 345 lines (+81/-71)
9 files modified
lib/lp/app/templates/base-layout-macros.pt (+4/-0)
lib/lp/translations/javascript/importqueue.js (+7/-43)
lib/lp/translations/javascript/languages.js (+48/-0)
lib/lp/translations/javascript/pofile.js (+5/-6)
lib/lp/translations/templates/pofile-translate.pt (+4/-4)
lib/lp/translations/templates/translation-import-queue-macros.pt (+4/-9)
lib/lp/translations/templates/translationmessage-translate.pt (+4/-4)
lib/lp/translations/templates/translations-macros.pt (+4/-5)
utilities/lp-deps.py (+1/-0)
To merge this branch: bzr merge lp:~adiroiban/launchpad/bug-561586
Reviewer Review Type Date Requested Status
Edwin Grubbs (community) code Approve
Review via email: mp+25565@code.launchpad.net

Commit message

Move translation javascript files to lib/lp/translations/javascript.

Description of the change

= Bug 561586 =

Rosetta javascript files should be moved from lib/canonical to lib/lp

== Proposed fix ==

Move javascript files to lib/lp

== Pre-implementation notes ==

None yet.

== Implementation details ==

rockstar suggested on #launchpad-dev to use "var namespace = Y.namespace" for YUI namespace, so I have changed this in all rosetta js files.

After a chat with mars on #launchpad-dev we agreed that it is best to have all javascript inclusion statements in base-layout-macros, rather than putting them in other templates.

I have split the translations.js file into importqueue.js and languages.js.

== Tests ==

The affected code is covered by Windmill tests.

== Demo and Q/A ==

To test the languages filtering in serieslanguage tables, log in with a user that has preferred languages (for admin you will need to add them).
Go to https://translations.launchpad.dev/ubuntu/hoary/ and the table should be filter with the preferred languages. Clicking "Show all languages" should show all languages.

To test the import queue you will need to first add a file in the import queue:
Login as admin and go to
https://translations.launchpad.dev/ubuntu/hoary/+source/evolution/+pots/man/es/+upload
Upload any .po file (you can rename any text file to .po)
The file should be listed an https://translations.launchpad.dev/ubuntu/hoary/+imports
Click the "Needs review"
A popup choose should appear.

= Make lint =

I was not able to run "make lint" on this branch as it is hanging after XmlLint.

To post a comment you must log in.
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Hi Adi,

This branch looks good.

merge-approved

-Edwin

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
2--- lib/lp/app/templates/base-layout-macros.pt 2010-04-22 17:18:29 +0000
3+++ lib/lp/app/templates/base-layout-macros.pt 2010-05-18 20:48:32 +0000
4@@ -222,6 +222,10 @@
5 tal:attributes="src string:${lp_js}/registry/team.js"></script>
6
7 <script type="text/javascript"
8+ tal:attributes="src string:${lp_js}/translations/importqueue.js"></script>
9+ <script type="text/javascript"
10+ tal:attributes="src string:${lp_js}/translations/languages.js"></script>
11+ <script type="text/javascript"
12 tal:attributes="src string:${lp_js}/translations/pofile.js"></script>
13
14 </tal:devmode>
15
16=== added directory 'lib/lp/translations/javascript'
17=== renamed file 'lib/canonical/launchpad/javascript/translations/translations.js' => 'lib/lp/translations/javascript/importqueue.js'
18--- lib/canonical/launchpad/javascript/translations/translations.js 2009-12-17 16:48:18 +0000
19+++ lib/lp/translations/javascript/importqueue.js 2010-05-18 20:48:32 +0000
20@@ -1,13 +1,13 @@
21 /* Copyright 2009 Canonical Ltd. This software is licensed under the
22 * GNU Affero General Public License version 3 (see the file LICENSE).
23 *
24- * @module TranslationImportQueue
25+ * @module lp.translations.importqueue
26 * @requires oop, event, node, widget, plugin, overlay,lazr.choiceedit
27 */
28
29-YUI.add('translations', function(Y) {
30+YUI.add('lp.translations.importqueue', function(Y) {
31
32-var translations = Y.namespace('translations');
33+var namespace = Y.namespace('lp.translations.importqueue');
34
35 /**
36 * HTML for the "this entry has error output" icon. This does not include the
37@@ -30,7 +30,7 @@
38 */
39 var compose_button = function(shown) {
40 return base_button +
41- (shown ?
42+ (shown ?
43 '<span class="treeExpanded sprite"></span>' :
44 '<span class="treeCollapsed sprite"></span>');
45 };
46@@ -40,8 +40,8 @@
47 * rendering) with one in the given state.
48 *
49 * This removes the entire old button and replaces it with a new one. That's
50- * one sure-fire way of getting rid of the old one's click-event handler, which
51- * is otherwise a brittle procedure and at the same time hard to test.
52+ * one sure-fire way of getting rid of the old one's click-event handler,
53+ * which is otherwise a brittle procedure and at the same time hard to test.
54 */
55 var alter_button = function(button, shown) {
56 var button_field = button.get('parentNode');
57@@ -165,15 +165,10 @@
58 button_markers.on('click', show_output);
59 };
60
61-var toggle_node_visibility = function(node, index, list) {
62- node.toggleClass('unseen');
63- node.toggleClass('seen');
64-};
65-
66 /**
67 * Set up the import queue page.
68 */
69-translations.initialize_import_queue_page = function (Y) {
70+namespace.initialize_import_queue_page = function (Y) {
71 // Show spinner while patching up the page, pre-fetchig the image.
72 var spinner_loader = Y.all('#spinner-loader');
73 spinner_loader.set('innerHTML', '<img src="/@@/spinner" alt="" />');
74@@ -188,37 +183,6 @@
75 spinner_loader.set('innerHTML', '');
76 };
77
78-
79-/**
80- * Set up the initial visibility for languages in a serieslanguages table.
81- */
82-translations.initialize_languages_table = function(Y) {
83- Y.all('.not-preferred-language').each(function(node, index, list) {
84- node.addClass('unseen');
85- });
86- Y.all('.preferred-language').each(function(node, index, list) {
87- node.addClass('seen');
88- });
89-};
90-
91-
92-/**
93- * Toggle visibility for languages in a serieslanguages table.
94- */
95-translations.toggle_languages_visibility = function(e) {
96- e.preventDefault();
97- Y.all('.not-preferred-language').each(toggle_node_visibility);
98- var toggle_button = e.currentTarget;
99- if (toggle_button.hasClass('all-languages-visible')) {
100- toggle_button.setContent('View all languages');
101- toggle_button.removeClass('all-languages-visible');
102- } else {
103- toggle_button.setContent('View only preferred languages');
104- toggle_button.addClass('all-languages-visible');
105- }
106-};
107-
108-
109 }, "0.1", {
110 // "oop" and "event" are required to fix known bugs in YUI, which
111 // are apparently fixed in a later version.
112
113=== added file 'lib/lp/translations/javascript/languages.js'
114--- lib/lp/translations/javascript/languages.js 1970-01-01 00:00:00 +0000
115+++ lib/lp/translations/javascript/languages.js 2010-05-18 20:48:32 +0000
116@@ -0,0 +1,48 @@
117+/* Copyright 2010 Canonical Ltd. This software is licensed under the
118+ * GNU Affero General Public License version 3 (see the file LICENSE).
119+ *
120+ * @module lp.translations.languages
121+ * @requires node
122+ */
123+
124+YUI.add('lp.translations.languages', function(Y) {
125+
126+var namespace = Y.namespace('lp.translations.languages');
127+
128+var toggle_node_visibility = function(node, index, list) {
129+ node.toggleClass('unseen');
130+ node.toggleClass('seen');
131+};
132+
133+/**
134+ * Set up the initial visibility for languages in a serieslanguages table.
135+ */
136+namespace.initialize_languages_table = function(Y) {
137+ Y.all('.not-preferred-language').each(function(node, index, list) {
138+ node.addClass('unseen');
139+ });
140+ Y.all('.preferred-language').each(function(node, index, list) {
141+ node.addClass('seen');
142+ });
143+};
144+
145+
146+/**
147+ * Toggle visibility for languages in a serieslanguages table.
148+ */
149+namespace.toggle_languages_visibility = function(e) {
150+ e.preventDefault();
151+ Y.all('.not-preferred-language').each(toggle_node_visibility);
152+ var toggle_button = e.currentTarget;
153+ if (toggle_button.hasClass('all-languages-visible')) {
154+ toggle_button.setContent('View all languages');
155+ toggle_button.removeClass('all-languages-visible');
156+ } else {
157+ toggle_button.setContent('View only preferred languages');
158+ toggle_button.addClass('all-languages-visible');
159+ }
160+};
161+
162+
163+}, "0.1", {"requires": ["node"]});
164+
165
166=== renamed file 'lib/canonical/launchpad/javascript/translations/pofile.js' => 'lib/lp/translations/javascript/pofile.js'
167--- lib/canonical/launchpad/javascript/translations/pofile.js 2010-04-23 16:09:20 +0000
168+++ lib/lp/translations/javascript/pofile.js 2010-05-18 20:48:32 +0000
169@@ -1,13 +1,12 @@
170 /** Copyright (c) 2009, Canonical Ltd. All rights reserved.
171 *
172- * @module lp.pofile
173+ * @module lp.translations.pofile
174 * @requires anim, cookie, event-key, event, node
175 */
176
177-YUI.add('lp.pofile', function(Y) {
178+YUI.add('lp.translations.pofile', function(Y) {
179
180-Y.log('loading lp.pofile');
181-var self = Y.namespace('lp.pofile');
182+var namespace = Y.namespace('lp.translations.pofile');
183
184 /**
185 * Function to disable/enable all suggestions as they are marked/unmarked
186@@ -515,7 +514,7 @@
187 /*
188 * Initialize Javascript code for a POFile +translate page.
189 */
190-self.initializePOFile = function(e) {
191+namespace.initializePOFile = function(e) {
192 try {
193 updateNotificationBox();
194 } catch (e) {
195@@ -528,7 +527,7 @@
196 /*
197 * Initialize Javascript code for a TranslationMessage +translate page.
198 */
199-self.initializeTranslationMessage = function(e) {
200+namespace.initializeTranslationMessage = function(e) {
201
202 try {
203 var fields = translations_order.split(' ');
204
205=== modified file 'lib/lp/translations/templates/pofile-translate.pt'
206--- lib/lp/translations/templates/pofile-translate.pt 2010-03-23 00:22:40 +0000
207+++ lib/lp/translations/templates/pofile-translate.pt 2010-05-18 20:48:32 +0000
208@@ -17,8 +17,8 @@
209 <script type="text/javascript">
210 registerLaunchpadFunction(insertAllExpansionButtons);
211
212- LPS.use('lp.pofile', function(Y) {
213- Y.on('domready', Y.lp.pofile.initializePOFile);
214+ LPS.use('lp.translations.pofile', function(Y) {
215+ Y.on('domready', Y.lp.translations.pofile.initializePOFile);
216 });
217
218 </script>
219@@ -98,7 +98,7 @@
220 </div>
221
222 <!-- Navigation -->
223- <metal:nav-pofile-subpages
224+ <metal:nav-pofile-subpages
225 use-macro="context/@@+translations-macros/nav-pofile-subpages" />
226
227 <!-- View filter and suggestions from alternative language. -->
228@@ -234,7 +234,7 @@
229 <tal:status replace="structure context/@@+access" />
230 <tal:contributors replace="structure context/@@+contributors" />
231 </tal:havepluralforms>
232- <metal:pofile-js-footer
233+ <metal:pofile-js-footer
234 use-macro="context/@@+translations-macros/pofile-js-footer" />
235 </div>
236 </body>
237
238=== modified file 'lib/lp/translations/templates/translation-import-queue-macros.pt'
239--- lib/lp/translations/templates/translation-import-queue-macros.pt 2010-02-11 20:52:20 +0000
240+++ lib/lp/translations/templates/translation-import-queue-macros.pt 2010-05-18 20:48:32 +0000
241@@ -11,16 +11,11 @@
242 <body>
243 <metal:translation-import-queue define-macro="translation-import-queue-content">
244 <script type="text/javascript" tal:content="view/choice_confs_js" />
245- <script
246- type="text/javascript"
247- tal:condition="devmode"
248- tal:attributes="src string:${icingroot}/build/translations/translations.js">
249- </script>
250
251 <script type="text/javascript">
252- LPS.use( 'translations', 'event', function(Y) {
253+ LPS.use('lp.translations.importqueue', 'event', function(Y) {
254 Y.on('domready', function(e) {
255- Y.translations.initialize_import_queue_page(Y);
256+ Y.lp.translations.importqueue.initialize_import_queue_page(Y);
257 });
258 });
259 </script>
260@@ -132,7 +127,7 @@
261 </tr>
262 <tr class="discreet secondary">
263 <td colspan="3">
264- Uploaded by
265+ Uploaded by
266 <a tal:replace="structure entry/importer/fmt:link">
267 Mark Shuttleworth
268 </a>
269@@ -150,7 +145,7 @@
270 <td colspan="3">
271 <span style="margin-right: 0.5em"
272 tal:condition="entry/import_into/title|nothing" >
273- Will be imported into
274+ Will be imported into
275 <a tal:content="entry/import_into/title"
276 tal:attributes="href entry/import_into/fmt:url"
277 >Foo</a>
278
279=== modified file 'lib/lp/translations/templates/translationmessage-translate.pt'
280--- lib/lp/translations/templates/translationmessage-translate.pt 2010-03-23 00:22:40 +0000
281+++ lib/lp/translations/templates/translationmessage-translate.pt 2010-05-18 20:48:32 +0000
282@@ -14,8 +14,8 @@
283 }
284 </style>
285 <script type="text/javascript">
286- LPS.use('node', 'lp.pofile', function(Y) {
287- Y.on('domready', Y.lp.pofile.initializeTranslationMessage);
288+ LPS.use('lp.translations.pofile', function(Y) {
289+ Y.on('domready', Y.lp.translations.pofile.initializeTranslationMessage);
290 });
291 </script>
292 </div>
293@@ -25,7 +25,7 @@
294 <tal:havepluralforms condition="view/has_plural_form_information">
295
296 <!-- Navigation -->
297- <metal:nav-pofile-subpages
298+ <metal:nav-pofile-subpages
299 use-macro="context/@@+translations-macros/nav-pofile-subpages" />
300
301 <!-- Alternative suggestions. -->
302@@ -86,7 +86,7 @@
303 replace="structure view/batchnav/@@+navigation-links-lower" />
304 <tal:status replace="structure context/pofile/@@+access" />
305 </tal:havepluralforms>
306- <metal:pofile-js-footer
307+ <metal:pofile-js-footer
308 use-macro="context/@@+translations-macros/pofile-js-footer" />
309 </div>
310
311
312=== modified file 'lib/lp/translations/templates/translations-macros.pt'
313--- lib/lp/translations/templates/translations-macros.pt 2010-03-24 18:36:55 +0000
314+++ lib/lp/translations/templates/translations-macros.pt 2010-05-18 20:48:32 +0000
315@@ -152,14 +152,13 @@
316
317 <metal:languages-table-js define-macro="languages-table-js">
318 <script type="text/javascript">
319- LPS.use("node", "translations", function(Y) {
320+ LPS.use('lp.translations.languages', 'event', function(Y) {
321 Y.on("click", function(e) {
322- Y.translations.toggle_languages_visibility(e);
323+ Y.lp.translations.languages.toggle_languages_visibility(e);
324 }, "#toggle-languages-visibility");
325- });
326- LPS.use( 'translations', 'event', function(Y) {
327+
328 Y.on('domready', function(e) {
329- Y.translations.initialize_languages_table(Y);
330+ Y.lp.translations.languages.initialize_languages_table(Y);
331 });
332 });
333 </script>
334
335=== modified file 'utilities/lp-deps.py'
336--- utilities/lp-deps.py 2010-04-29 15:21:05 +0000
337+++ utilities/lp-deps.py 2010-05-18 20:48:32 +0000
338@@ -21,6 +21,7 @@
339 JS_DIRSET = [
340 (os.path.join('lib', 'lp', 'code', 'javascript'), 'code'),
341 (os.path.join('lib', 'lp', 'registry', 'javascript'), 'registry'),
342+ (os.path.join('lib', 'lp', 'translations', 'javascript'), 'translations'),
343 ]
344 ICING_ROOT = os.path.join(TOP, 'lib', 'canonical', 'launchpad', 'icing')
345 ICING_BUILD = os.path.join(ICING_ROOT, 'build')