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
=== modified file 'lib/lp/app/templates/base-layout-macros.pt'
--- lib/lp/app/templates/base-layout-macros.pt 2010-04-22 17:18:29 +0000
+++ lib/lp/app/templates/base-layout-macros.pt 2010-05-18 20:48:32 +0000
@@ -222,6 +222,10 @@
222 tal:attributes="src string:${lp_js}/registry/team.js"></script>222 tal:attributes="src string:${lp_js}/registry/team.js"></script>
223223
224 <script type="text/javascript"224 <script type="text/javascript"
225 tal:attributes="src string:${lp_js}/translations/importqueue.js"></script>
226 <script type="text/javascript"
227 tal:attributes="src string:${lp_js}/translations/languages.js"></script>
228 <script type="text/javascript"
225 tal:attributes="src string:${lp_js}/translations/pofile.js"></script>229 tal:attributes="src string:${lp_js}/translations/pofile.js"></script>
226230
227 </tal:devmode>231 </tal:devmode>
228232
=== added directory 'lib/lp/translations/javascript'
=== renamed file 'lib/canonical/launchpad/javascript/translations/translations.js' => 'lib/lp/translations/javascript/importqueue.js'
--- lib/canonical/launchpad/javascript/translations/translations.js 2009-12-17 16:48:18 +0000
+++ lib/lp/translations/javascript/importqueue.js 2010-05-18 20:48:32 +0000
@@ -1,13 +1,13 @@
1/* Copyright 2009 Canonical Ltd. This software is licensed under the1/* Copyright 2009 Canonical Ltd. This software is licensed under the
2 * GNU Affero General Public License version 3 (see the file LICENSE).2 * GNU Affero General Public License version 3 (see the file LICENSE).
3 *3 *
4 * @module TranslationImportQueue4 * @module lp.translations.importqueue
5 * @requires oop, event, node, widget, plugin, overlay,lazr.choiceedit5 * @requires oop, event, node, widget, plugin, overlay,lazr.choiceedit
6 */6 */
77
8YUI.add('translations', function(Y) {8YUI.add('lp.translations.importqueue', function(Y) {
99
10var translations = Y.namespace('translations');10var namespace = Y.namespace('lp.translations.importqueue');
1111
12/**12/**
13 * HTML for the "this entry has error output" icon. This does not include the13 * HTML for the "this entry has error output" icon. This does not include the
@@ -30,7 +30,7 @@
30 */30 */
31var compose_button = function(shown) {31var compose_button = function(shown) {
32 return base_button +32 return base_button +
33 (shown ? 33 (shown ?
34 '<span class="treeExpanded sprite"></span>' :34 '<span class="treeExpanded sprite"></span>' :
35 '<span class="treeCollapsed sprite"></span>');35 '<span class="treeCollapsed sprite"></span>');
36};36};
@@ -40,8 +40,8 @@
40 * rendering) with one in the given state.40 * rendering) with one in the given state.
41 *41 *
42 * This removes the entire old button and replaces it with a new one. That's42 * This removes the entire old button and replaces it with a new one. That's
43 * one sure-fire way of getting rid of the old one's click-event handler, which43 * one sure-fire way of getting rid of the old one's click-event handler,
44 * is otherwise a brittle procedure and at the same time hard to test.44 * which is otherwise a brittle procedure and at the same time hard to test.
45 */45 */
46var alter_button = function(button, shown) {46var alter_button = function(button, shown) {
47 var button_field = button.get('parentNode');47 var button_field = button.get('parentNode');
@@ -165,15 +165,10 @@
165 button_markers.on('click', show_output);165 button_markers.on('click', show_output);
166};166};
167167
168var toggle_node_visibility = function(node, index, list) {
169 node.toggleClass('unseen');
170 node.toggleClass('seen');
171};
172
173/**168/**
174 * Set up the import queue page.169 * Set up the import queue page.
175 */170 */
176translations.initialize_import_queue_page = function (Y) {171namespace.initialize_import_queue_page = function (Y) {
177 // Show spinner while patching up the page, pre-fetchig the image.172 // Show spinner while patching up the page, pre-fetchig the image.
178 var spinner_loader = Y.all('#spinner-loader');173 var spinner_loader = Y.all('#spinner-loader');
179 spinner_loader.set('innerHTML', '<img src="/@@/spinner" alt="" />');174 spinner_loader.set('innerHTML', '<img src="/@@/spinner" alt="" />');
@@ -188,37 +183,6 @@
188 spinner_loader.set('innerHTML', '');183 spinner_loader.set('innerHTML', '');
189};184};
190185
191
192/**
193 * Set up the initial visibility for languages in a serieslanguages table.
194 */
195translations.initialize_languages_table = function(Y) {
196 Y.all('.not-preferred-language').each(function(node, index, list) {
197 node.addClass('unseen');
198 });
199 Y.all('.preferred-language').each(function(node, index, list) {
200 node.addClass('seen');
201 });
202};
203
204
205/**
206 * Toggle visibility for languages in a serieslanguages table.
207 */
208translations.toggle_languages_visibility = function(e) {
209 e.preventDefault();
210 Y.all('.not-preferred-language').each(toggle_node_visibility);
211 var toggle_button = e.currentTarget;
212 if (toggle_button.hasClass('all-languages-visible')) {
213 toggle_button.setContent('View all languages');
214 toggle_button.removeClass('all-languages-visible');
215 } else {
216 toggle_button.setContent('View only preferred languages');
217 toggle_button.addClass('all-languages-visible');
218 }
219};
220
221
222}, "0.1", {186}, "0.1", {
223 // "oop" and "event" are required to fix known bugs in YUI, which187 // "oop" and "event" are required to fix known bugs in YUI, which
224 // are apparently fixed in a later version.188 // are apparently fixed in a later version.
225189
=== added file 'lib/lp/translations/javascript/languages.js'
--- lib/lp/translations/javascript/languages.js 1970-01-01 00:00:00 +0000
+++ lib/lp/translations/javascript/languages.js 2010-05-18 20:48:32 +0000
@@ -0,0 +1,48 @@
1/* Copyright 2010 Canonical Ltd. This software is licensed under the
2 * GNU Affero General Public License version 3 (see the file LICENSE).
3 *
4 * @module lp.translations.languages
5 * @requires node
6 */
7
8YUI.add('lp.translations.languages', function(Y) {
9
10var namespace = Y.namespace('lp.translations.languages');
11
12var toggle_node_visibility = function(node, index, list) {
13 node.toggleClass('unseen');
14 node.toggleClass('seen');
15};
16
17/**
18 * Set up the initial visibility for languages in a serieslanguages table.
19 */
20namespace.initialize_languages_table = function(Y) {
21 Y.all('.not-preferred-language').each(function(node, index, list) {
22 node.addClass('unseen');
23 });
24 Y.all('.preferred-language').each(function(node, index, list) {
25 node.addClass('seen');
26 });
27};
28
29
30/**
31 * Toggle visibility for languages in a serieslanguages table.
32 */
33namespace.toggle_languages_visibility = function(e) {
34 e.preventDefault();
35 Y.all('.not-preferred-language').each(toggle_node_visibility);
36 var toggle_button = e.currentTarget;
37 if (toggle_button.hasClass('all-languages-visible')) {
38 toggle_button.setContent('View all languages');
39 toggle_button.removeClass('all-languages-visible');
40 } else {
41 toggle_button.setContent('View only preferred languages');
42 toggle_button.addClass('all-languages-visible');
43 }
44};
45
46
47}, "0.1", {"requires": ["node"]});
48
049
=== renamed file 'lib/canonical/launchpad/javascript/translations/pofile.js' => 'lib/lp/translations/javascript/pofile.js'
--- lib/canonical/launchpad/javascript/translations/pofile.js 2010-04-23 16:09:20 +0000
+++ lib/lp/translations/javascript/pofile.js 2010-05-18 20:48:32 +0000
@@ -1,13 +1,12 @@
1/** Copyright (c) 2009, Canonical Ltd. All rights reserved.1/** Copyright (c) 2009, Canonical Ltd. All rights reserved.
2 *2 *
3 * @module lp.pofile3 * @module lp.translations.pofile
4 * @requires anim, cookie, event-key, event, node4 * @requires anim, cookie, event-key, event, node
5 */5 */
66
7YUI.add('lp.pofile', function(Y) {7YUI.add('lp.translations.pofile', function(Y) {
88
9Y.log('loading lp.pofile');9var namespace = Y.namespace('lp.translations.pofile');
10var self = Y.namespace('lp.pofile');
1110
12/**11/**
13 * Function to disable/enable all suggestions as they are marked/unmarked12 * Function to disable/enable all suggestions as they are marked/unmarked
@@ -515,7 +514,7 @@
515/*514/*
516 * Initialize Javascript code for a POFile +translate page.515 * Initialize Javascript code for a POFile +translate page.
517 */516 */
518self.initializePOFile = function(e) {517namespace.initializePOFile = function(e) {
519 try {518 try {
520 updateNotificationBox();519 updateNotificationBox();
521 } catch (e) {520 } catch (e) {
@@ -528,7 +527,7 @@
528/*527/*
529 * Initialize Javascript code for a TranslationMessage +translate page.528 * Initialize Javascript code for a TranslationMessage +translate page.
530 */529 */
531self.initializeTranslationMessage = function(e) {530namespace.initializeTranslationMessage = function(e) {
532531
533 try {532 try {
534 var fields = translations_order.split(' ');533 var fields = translations_order.split(' ');
535534
=== modified file 'lib/lp/translations/templates/pofile-translate.pt'
--- lib/lp/translations/templates/pofile-translate.pt 2010-03-23 00:22:40 +0000
+++ lib/lp/translations/templates/pofile-translate.pt 2010-05-18 20:48:32 +0000
@@ -17,8 +17,8 @@
17 <script type="text/javascript">17 <script type="text/javascript">
18 registerLaunchpadFunction(insertAllExpansionButtons);18 registerLaunchpadFunction(insertAllExpansionButtons);
1919
20 LPS.use('lp.pofile', function(Y) {20 LPS.use('lp.translations.pofile', function(Y) {
21 Y.on('domready', Y.lp.pofile.initializePOFile);21 Y.on('domready', Y.lp.translations.pofile.initializePOFile);
22 });22 });
2323
24 </script>24 </script>
@@ -98,7 +98,7 @@
98 </div>98 </div>
9999
100 <!-- Navigation -->100 <!-- Navigation -->
101 <metal:nav-pofile-subpages 101 <metal:nav-pofile-subpages
102 use-macro="context/@@+translations-macros/nav-pofile-subpages" />102 use-macro="context/@@+translations-macros/nav-pofile-subpages" />
103103
104 <!-- View filter and suggestions from alternative language. -->104 <!-- View filter and suggestions from alternative language. -->
@@ -234,7 +234,7 @@
234 <tal:status replace="structure context/@@+access" />234 <tal:status replace="structure context/@@+access" />
235 <tal:contributors replace="structure context/@@+contributors" />235 <tal:contributors replace="structure context/@@+contributors" />
236 </tal:havepluralforms>236 </tal:havepluralforms>
237 <metal:pofile-js-footer 237 <metal:pofile-js-footer
238 use-macro="context/@@+translations-macros/pofile-js-footer" />238 use-macro="context/@@+translations-macros/pofile-js-footer" />
239 </div>239 </div>
240 </body>240 </body>
241241
=== modified file 'lib/lp/translations/templates/translation-import-queue-macros.pt'
--- lib/lp/translations/templates/translation-import-queue-macros.pt 2010-02-11 20:52:20 +0000
+++ lib/lp/translations/templates/translation-import-queue-macros.pt 2010-05-18 20:48:32 +0000
@@ -11,16 +11,11 @@
11<body>11<body>
12 <metal:translation-import-queue define-macro="translation-import-queue-content">12 <metal:translation-import-queue define-macro="translation-import-queue-content">
13 <script type="text/javascript" tal:content="view/choice_confs_js" />13 <script type="text/javascript" tal:content="view/choice_confs_js" />
14 <script
15 type="text/javascript"
16 tal:condition="devmode"
17 tal:attributes="src string:${icingroot}/build/translations/translations.js">
18 </script>
1914
20 <script type="text/javascript">15 <script type="text/javascript">
21 LPS.use( 'translations', 'event', function(Y) {16 LPS.use('lp.translations.importqueue', 'event', function(Y) {
22 Y.on('domready', function(e) {17 Y.on('domready', function(e) {
23 Y.translations.initialize_import_queue_page(Y);18 Y.lp.translations.importqueue.initialize_import_queue_page(Y);
24 });19 });
25 });20 });
26 </script>21 </script>
@@ -132,7 +127,7 @@
132 </tr>127 </tr>
133 <tr class="discreet secondary">128 <tr class="discreet secondary">
134 <td colspan="3">129 <td colspan="3">
135 Uploaded by 130 Uploaded by
136 <a tal:replace="structure entry/importer/fmt:link">131 <a tal:replace="structure entry/importer/fmt:link">
137 Mark Shuttleworth132 Mark Shuttleworth
138 </a>133 </a>
@@ -150,7 +145,7 @@
150 <td colspan="3">145 <td colspan="3">
151 <span style="margin-right: 0.5em"146 <span style="margin-right: 0.5em"
152 tal:condition="entry/import_into/title|nothing" >147 tal:condition="entry/import_into/title|nothing" >
153 Will be imported into 148 Will be imported into
154 <a tal:content="entry/import_into/title"149 <a tal:content="entry/import_into/title"
155 tal:attributes="href entry/import_into/fmt:url"150 tal:attributes="href entry/import_into/fmt:url"
156 >Foo</a>151 >Foo</a>
157152
=== modified file 'lib/lp/translations/templates/translationmessage-translate.pt'
--- lib/lp/translations/templates/translationmessage-translate.pt 2010-03-23 00:22:40 +0000
+++ lib/lp/translations/templates/translationmessage-translate.pt 2010-05-18 20:48:32 +0000
@@ -14,8 +14,8 @@
14 }14 }
15 </style>15 </style>
16 <script type="text/javascript">16 <script type="text/javascript">
17 LPS.use('node', 'lp.pofile', function(Y) {17 LPS.use('lp.translations.pofile', function(Y) {
18 Y.on('domready', Y.lp.pofile.initializeTranslationMessage);18 Y.on('domready', Y.lp.translations.pofile.initializeTranslationMessage);
19 });19 });
20 </script>20 </script>
21 </div>21 </div>
@@ -25,7 +25,7 @@
25 <tal:havepluralforms condition="view/has_plural_form_information">25 <tal:havepluralforms condition="view/has_plural_form_information">
2626
27 <!-- Navigation -->27 <!-- Navigation -->
28 <metal:nav-pofile-subpages 28 <metal:nav-pofile-subpages
29 use-macro="context/@@+translations-macros/nav-pofile-subpages" />29 use-macro="context/@@+translations-macros/nav-pofile-subpages" />
3030
31 <!-- Alternative suggestions. -->31 <!-- Alternative suggestions. -->
@@ -86,7 +86,7 @@
86 replace="structure view/batchnav/@@+navigation-links-lower" />86 replace="structure view/batchnav/@@+navigation-links-lower" />
87 <tal:status replace="structure context/pofile/@@+access" />87 <tal:status replace="structure context/pofile/@@+access" />
88 </tal:havepluralforms>88 </tal:havepluralforms>
89 <metal:pofile-js-footer 89 <metal:pofile-js-footer
90 use-macro="context/@@+translations-macros/pofile-js-footer" />90 use-macro="context/@@+translations-macros/pofile-js-footer" />
91 </div>91 </div>
9292
9393
=== modified file 'lib/lp/translations/templates/translations-macros.pt'
--- lib/lp/translations/templates/translations-macros.pt 2010-03-24 18:36:55 +0000
+++ lib/lp/translations/templates/translations-macros.pt 2010-05-18 20:48:32 +0000
@@ -152,14 +152,13 @@
152152
153<metal:languages-table-js define-macro="languages-table-js">153<metal:languages-table-js define-macro="languages-table-js">
154 <script type="text/javascript">154 <script type="text/javascript">
155 LPS.use("node", "translations", function(Y) {155 LPS.use('lp.translations.languages', 'event', function(Y) {
156 Y.on("click", function(e) {156 Y.on("click", function(e) {
157 Y.translations.toggle_languages_visibility(e);157 Y.lp.translations.languages.toggle_languages_visibility(e);
158 }, "#toggle-languages-visibility");158 }, "#toggle-languages-visibility");
159 });159
160 LPS.use( 'translations', 'event', function(Y) {
161 Y.on('domready', function(e) {160 Y.on('domready', function(e) {
162 Y.translations.initialize_languages_table(Y);161 Y.lp.translations.languages.initialize_languages_table(Y);
163 });162 });
164 });163 });
165 </script>164 </script>
166165
=== modified file 'utilities/lp-deps.py'
--- utilities/lp-deps.py 2010-04-29 15:21:05 +0000
+++ utilities/lp-deps.py 2010-05-18 20:48:32 +0000
@@ -21,6 +21,7 @@
21JS_DIRSET = [21JS_DIRSET = [
22 (os.path.join('lib', 'lp', 'code', 'javascript'), 'code'),22 (os.path.join('lib', 'lp', 'code', 'javascript'), 'code'),
23 (os.path.join('lib', 'lp', 'registry', 'javascript'), 'registry'),23 (os.path.join('lib', 'lp', 'registry', 'javascript'), 'registry'),
24 (os.path.join('lib', 'lp', 'translations', 'javascript'), 'translations'),
24 ]25 ]
25ICING_ROOT = os.path.join(TOP, 'lib', 'canonical', 'launchpad', 'icing')26ICING_ROOT = os.path.join(TOP, 'lib', 'canonical', 'launchpad', 'icing')
26ICING_BUILD = os.path.join(ICING_ROOT, 'build')27ICING_BUILD = os.path.join(ICING_ROOT, 'build')