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

Proposed by Adi Roiban
Status: Merged
Merged at revision: not available
Proposed branch: lp:~adiroiban/launchpad/bug-492375
Merge into: lp:launchpad
Diff against target: 509 lines (+251/-28)
14 files modified
lib/canonical/launchpad/javascript/translations/translations.js (+37/-1)
lib/lp/translations/browser/distroseries.py (+9/-1)
lib/lp/translations/browser/productseries.py (+11/-3)
lib/lp/translations/stories/translations/55-rosetta-potemplates.txt (+1/-1)
lib/lp/translations/templates/distribution-translations.pt (+9/-3)
lib/lp/translations/templates/distroseries-langchart.pt (+16/-1)
lib/lp/translations/templates/distroseries-translations.pt (+8/-0)
lib/lp/translations/templates/object-pots.pt (+2/-2)
lib/lp/translations/templates/product-translations.pt (+9/-2)
lib/lp/translations/templates/productseries-translations-languages.pt (+15/-3)
lib/lp/translations/templates/productseries-translations.pt (+10/-2)
lib/lp/translations/templates/translations-macros.pt (+36/-0)
lib/lp/translations/windmill/tests/test_languages.py (+5/-9)
lib/lp/translations/windmill/tests/test_serieslanguages.py (+83/-0)
To merge this branch: bzr merge lp:~adiroiban/launchpad/bug-492375
Reviewer Review Type Date Requested Status
Michael Nelson (community) ui Approve
Muharem Hrnjadovic (community) code-review Approve
Review via email: mp+16279@code.launchpad.net

Commit message

In a series languages table, at pageload, only display preferred languages.

To post a comment you must log in.
Revision history for this message
Adi Roiban (adiroiban) wrote :

= Bug 492375 =
Suppose I want to translate Ubuntu into Romanian.
I will go to: https://translations.edge.launchpad.net/ and click on "Ubuntu Karmic (9.10)"
The next page will be :
https://translations.edge.launchpad.net/ubuntu/karmic/+translations
Then I have to scroll all along the page and search for Romanian in that big and compact list.

== Proposed fix ==
At first page load, only display users preferred languages and display a link for viewing all languages.

Just like we do for source packages:
https://translations.launchpad.net/ubuntu/karmic/+source/gfxboot-theme-ubuntu/

== Pre-implementation notes ==

After a long chat with Danilo and Jeroen we decided it is best to put the class selection login in the template with some help from the view.

== Tests ==

bin/test --layer=TranslationsWindmillLayer -D -t serieslanguages

UI Review screenshots:
 * http://launchpadlibrarian.net/36485928/preferred.png
 * http://launchpadlibrarian.net/36485936/all-languages.png

== Demo and Q/A ==

Access one of the page presenting language series.
For example http://translations.launchpad.dev/ubuntu

If you are not logged in, you will see a list of languages obtained using geoip.
You can click the "View all languages" and the table should display all langauges for Ubuntu.

If you are logged in, it will show only your preferred languages.

Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :
Download full text (20.5 KiB)

Adi Roiban wrote:
> Adi Roiban has proposed merging lp:~adiroiban/launchpad/bug-492375
> into lp:launchpad/devel.
>
> Requested reviews:
> Canonical Launchpad Engineering (launchpad)
> Related bugs:
> #492375 At first, display only translations statistics for preferred
> languages
> https://bugs.launchpad.net/bugs/492375
Hello Adi,

thank you very much for preparing this branch which generally looks
very good. Please see my comments below for more detail.

[..]

> == Tests ==
>
> bin/test --layer=TranslationsWindmillLayer -D -t serieslanguages
All tests pass except for the one "that always fails" as discussed on IRC:
{{{
<adiroiban> al-maisan: ah... that is part of user.ensure_login(self.client)
<adiroiban> and it fails for all windmill tests
}}}

> == Demo and Q/A ==
>
> Access one of the page presenting language series.
> For example http://translations.launchpad.dev/ubuntu
>
> If you are not logged in, you will see a list of languages obtained
> using geoip.
> You can click the "View all languages" and the table should display
> all langauges for Ubuntu.
>
> If you are logged in, it will show only your preferred languages.
This works as described.

> === modified file 'lib/canonical/launchpad/javascript/translations/translations.js'
> --- lib/canonical/launchpad/javascript/translations/translations.js 2009-11-24 09:30:01 +0000
> +++ lib/canonical/launchpad/javascript/translations/translations.js 2009-12-17 14:38:47 +0000
> @@ -116,7 +116,7 @@
> * which is defined in a code fragment that is included in the page via TAL.
> */
> var init_status_choice = function(content_box, index, list) {
> - content_box.setStyle('display', '')
> + content_box.setStyle('display', '');
> var conf = choice_confs[index];
> conf.title = 'Change status to';
> conf.contentBox = content_box;
> @@ -165,6 +165,11 @@
> button_markers.on('click', show_output);
> };
>
> +var toggle_node_visibility = function(node, index, list) {
> + node.toggleClass('unseen');
> + node.toggleClass('seen');
> +};
> +
> /**
> * Set up the import queue page.
> */
> @@ -183,6 +188,37 @@
> spinner_loader.set('innerHTML', '');
> };
>
> +
> +/**
> + * Set up initial the visibility for languages in a serieslanguages table.
"Set up the initial visibility.." ?

> + */
> +translations.initialize_languages_table = function(Y) {
> + Y.all('.not-preferred-language').each(function(node, index, list) {
> + node.addClass('unseen');
> + });
> + Y.all('.preferred-language').each(function(node, index, list) {
> + node.addClass('seen');
> + });
> +};
> +
> +
> +/**
> + * Toggle visibility for languages in a serieslanguages table.
> + */
> +translations.toggle_languages_visibility = function(e) {
> + e.preventDefault();
> + Y.all('.not-preferred-language').each(toggle_node_visibility);
> + var toggle_button = e.currentTarget;
> + if (toggle_button.hasClass('all-languages-visible')) {
> + toggle_button.setContent('View All Languages');
> + toggle_button.removeClass('all-languages-visible');
> + } else {
> + toggle_button.setContent('View Only Preferred Languages');
> + toggle_button...

Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Looks good, thanks Adi!

review: Approve (code-review)
Revision history for this message
Michael Nelson (michael.nelson) wrote :

Hi Adi, this is great!

I'm really glad you all agreed on the JS version - it's great being able to switch between preferred and all languages without a page-load.

I've only got two thoughts regarding things that were not actually changed by your branch:

First, the capitalization of the "Choose preferred languages - View all languages" links (only first word capitalized, as outlined here: https://dev.launchpad.net/UserInterfaceWording#Capitalization

(Just for reference, there are a bunch of useful links for stuff like that at https://dev.launchpad.net/UI/Reviews)

Second, it's a little bit strange that if my preferred language is just "English", then all languages are displayed, but I still see the 'View all languages'/'View preferred languages'. If this is expected that all languages are displayed when a persons preferred language is "English", then I think we should hide the toggle link in that case?

What do you think?

review: Approve (ui)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/javascript/translations/translations.js'
--- lib/canonical/launchpad/javascript/translations/translations.js 2009-11-24 09:30:01 +0000
+++ lib/canonical/launchpad/javascript/translations/translations.js 2009-12-21 17:29:17 +0000
@@ -116,7 +116,7 @@
116 * which is defined in a code fragment that is included in the page via TAL.116 * which is defined in a code fragment that is included in the page via TAL.
117 */117 */
118var init_status_choice = function(content_box, index, list) {118var init_status_choice = function(content_box, index, list) {
119 content_box.setStyle('display', '')119 content_box.setStyle('display', '');
120 var conf = choice_confs[index];120 var conf = choice_confs[index];
121 conf.title = 'Change status to';121 conf.title = 'Change status to';
122 conf.contentBox = content_box;122 conf.contentBox = content_box;
@@ -165,6 +165,11 @@
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
168/**173/**
169 * Set up the import queue page.174 * Set up the import queue page.
170 */175 */
@@ -183,6 +188,37 @@
183 spinner_loader.set('innerHTML', '');188 spinner_loader.set('innerHTML', '');
184};189};
185190
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
186}, "0.1", {222}, "0.1", {
187 // "oop" and "event" are required to fix known bugs in YUI, which223 // "oop" and "event" are required to fix known bugs in YUI, which
188 // are apparently fixed in a later version.224 // are apparently fixed in a later version.
189225
=== modified file 'lib/lp/translations/browser/distroseries.py'
--- lib/lp/translations/browser/distroseries.py 2009-10-30 10:09:17 +0000
+++ lib/lp/translations/browser/distroseries.py 2009-12-21 17:29:17 +0000
@@ -107,7 +107,6 @@
107 else:107 else:
108 self.adminlabel = 'Settings for language packs'108 self.adminlabel = 'Settings for language packs'
109109
110
111 @cachedproperty110 @cachedproperty
112 def unused_language_packs(self):111 def unused_language_packs(self):
113 unused_language_packs = helpers.shortlist(self.context.language_packs)112 unused_language_packs = helpers.shortlist(self.context.language_packs)
@@ -236,6 +235,14 @@
236235
237 return sorted(distroserieslangs, key=lambda a: a.language.englishname)236 return sorted(distroserieslangs, key=lambda a: a.language.englishname)
238237
238 def isPreferredLanguage(self, language):
239 # if there are no preferred languages, mark all
240 # languages as preferred
241 if (len(self.translatable_languages) == 0):
242 return True
243 else:
244 return language in self.translatable_languages
245
239 @property246 @property
240 def potemplates(self):247 def potemplates(self):
241 return list(self.context.getCurrentTranslationTemplates())248 return list(self.context.getCurrentTranslationTemplates())
@@ -245,6 +252,7 @@
245 """Is this DistroSeries the translation focus."""252 """Is this DistroSeries the translation focus."""
246 return self.context.distribution.translation_focus == self.context253 return self.context.distribution.translation_focus == self.context
247254
255
248class DistroSeriesTranslationsMenu(NavigationMenu):256class DistroSeriesTranslationsMenu(NavigationMenu):
249257
250 usedfor = IDistroSeries258 usedfor = IDistroSeries
251259
=== modified file 'lib/lp/translations/browser/productseries.py'
--- lib/lp/translations/browser/productseries.py 2009-12-10 10:46:53 +0000
+++ lib/lp/translations/browser/productseries.py 2009-12-21 17:29:17 +0000
@@ -57,6 +57,7 @@
5757
58class ProductSeriesTranslationsMenuMixIn:58class ProductSeriesTranslationsMenuMixIn:
59 """Translation menu for `IProductSeries`."""59 """Translation menu for `IProductSeries`."""
60
60 def overview(self):61 def overview(self):
61 """Return a link to the overview page."""62 """Return a link to the overview page."""
62 return Link('', 'Overview')63 return Link('', 'Overview')
@@ -275,7 +276,7 @@
275 warning = (276 warning = (
276 "A file could not be uploaded because its "277 "A file could not be uploaded because its "
277 "name matched multiple existing uploads, for "278 "name matched multiple existing uploads, for "
278 "different templates." )279 "different templates.")
279 ul_conflicts = (280 ul_conflicts = (
280 "The conflicting file name was:<br /> "281 "The conflicting file name was:<br /> "
281 "<ul><li>%s</li></ul>" % cgi.escape(conflicts[0]))282 "<ul><li>%s</li></ul>" % cgi.escape(conflicts[0]))
@@ -378,6 +379,14 @@
378 return sorted(productserieslangs,379 return sorted(productserieslangs,
379 key=lambda a: a.language.englishname)380 key=lambda a: a.language.englishname)
380381
382 def isPreferredLanguage(self, language):
383 # if there are no preferred languages, mark all
384 # languages as preferred
385 if (len(self.translatable_languages) == 0):
386 return True
387 else:
388 return language in self.translatable_languages
389
381 @property390 @property
382 def has_translation_documentation(self):391 def has_translation_documentation(self):
383 """Are there translation instructions for this product."""392 """Are there translation instructions for this product."""
@@ -421,8 +430,7 @@
421 def change_settings_action(self, action, data):430 def change_settings_action(self, action, data):
422 """Change the translation settings."""431 """Change the translation settings."""
423 if (self.context.translations_autoimport_mode !=432 if (self.context.translations_autoimport_mode !=
424 data['translations_autoimport_mode']433 data['translations_autoimport_mode']):
425 ):
426 self.updateContextFromData(data)434 self.updateContextFromData(data)
427 # Request an initial upload of translation files.435 # Request an initial upload of translation files.
428 getUtility(IRosettaUploadJobSource).create(436 getUtility(IRosettaUploadJobSource).create(
429437
=== modified file 'lib/lp/translations/stories/translations/55-rosetta-potemplates.txt'
--- lib/lp/translations/stories/translations/55-rosetta-potemplates.txt 2009-06-12 16:36:02 +0000
+++ lib/lp/translations/stories/translations/55-rosetta-potemplates.txt 2009-12-21 17:29:17 +0000
@@ -90,7 +90,7 @@
90Next, if he chooses to view all the languages, he should see Japanese90Next, if he chooses to view all the languages, he should see Japanese
91among the languages on the page.91among the languages on the page.
9292
93 >>> browser.getLink('View Template & All Languages...').click()93 >>> browser.getLink('View template & all languages...').click()
94 >>> 'Japanese' in browser.contents94 >>> 'Japanese' in browser.contents
95 True95 True
9696
9797
=== modified file 'lib/lp/translations/templates/distribution-translations.pt'
--- lib/lp/translations/templates/distribution-translations.pt 2009-11-07 16:14:22 +0000
+++ lib/lp/translations/templates/distribution-translations.pt 2009-12-21 17:29:17 +0000
@@ -1,13 +1,19 @@
1
2<html1<html
3 xmlns="http://www.w3.org/1999/xhtml"2 xmlns="http://www.w3.org/1999/xhtml"
4 xmlns:tal="http://xml.zope.org/namespaces/tal"3 xmlns:tal="http://xml.zope.org/namespaces/tal"
5 xmlns:metal="http://xml.zope.org/namespaces/metal"4 xmlns:metal="http://xml.zope.org/namespaces/metal"
6 xmlns:i18n="http://xml.zope.org/namespaces/i18n"5 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
7 metal:use-macro="view/macro:page/main_only"6 metal:use-macro="view/macro:page/main_only">
8>
97
10 <body>8 <body>
9
10 <div metal:fill-slot="head_epilogue">
11 <metal:translations-js
12 use-macro="context/@@+translations-macros/translations-js" />
13 <metal:languages-table-js
14 use-macro="context/@@+translations-macros/languages-table-js" />
15 </div>
16
11 <div metal:fill-slot="main">17 <div metal:fill-slot="main">
12 <div class="translation-help-links">18 <div class="translation-help-links">
13 <a href="https://help.launchpad.net/Translations"19 <a href="https://help.launchpad.net/Translations"
1420
=== modified file 'lib/lp/translations/templates/distroseries-langchart.pt'
--- lib/lp/translations/templates/distroseries-langchart.pt 2009-07-17 17:59:07 +0000
+++ lib/lp/translations/templates/distroseries-langchart.pt 2009-12-21 17:29:17 +0000
@@ -25,7 +25,18 @@
25 </thead>25 </thead>
2626
27 <tbody>27 <tbody>
28 <tr tal:repeat="drlang view/distroserieslanguages">28 <tal:loop tal:repeat="drlang view/distroserieslanguages">
29 <tal:preferred
30 condition="python: view.isPreferredLanguage(drlang.language)">
31 <tal:set-class
32 define="global series_language_class string:preferred-language" />
33 </tal:preferred>
34 <tal:not-preferred
35 condition="not:python: view.isPreferredLanguage(drlang.language)">
36 <tal:set-class
37 define="global series_language_class string:not-preferred-language" />
38 </tal:not-preferred>
39 <tr tal:attributes="class series_language_class">
29 <td>40 <td>
30 <a tal:attributes="href string:${drlang/fmt:url}"41 <a tal:attributes="href string:${drlang/fmt:url}"
31 tal:content="drlang/language/englishname">42 tal:content="drlang/language/englishname">
@@ -72,6 +83,10 @@
72 </tal:count>83 </tal:count>
73 </td>84 </td>
74 </tr>85 </tr>
86 </tal:loop>
75 </tbody>87 </tbody>
76 </table>88 </table>
89 <metal:languages-table-actions
90 use-macro="context/@@+translations-macros/languages-table-actions" />
91
77</tal:root>92</tal:root>
7893
=== modified file 'lib/lp/translations/templates/distroseries-translations.pt'
--- lib/lp/translations/templates/distroseries-translations.pt 2009-10-23 06:42:09 +0000
+++ lib/lp/translations/templates/distroseries-translations.pt 2009-12-21 17:29:17 +0000
@@ -5,6 +5,14 @@
5 metal:use-macro="view/macro:page/main_only">5 metal:use-macro="view/macro:page/main_only">
66
7 <body>7 <body>
8
9 <div metal:fill-slot="head_epilogue">
10 <metal:translations-js
11 use-macro="context/@@+translations-macros/translations-js" />
12 <metal:languages-table-js
13 use-macro="context/@@+translations-macros/languages-table-js" />
14 </div>
15
8 <div metal:fill-slot="main">16 <div metal:fill-slot="main">
9 <div class="translation-help-links">17 <div class="translation-help-links">
10 <a href="https://help.launchpad.net/Translations"18 <a href="https://help.launchpad.net/Translations"
1119
=== modified file 'lib/lp/translations/templates/object-pots.pt'
--- lib/lp/translations/templates/object-pots.pt 2009-07-24 11:25:36 +0000
+++ lib/lp/translations/templates/object-pots.pt 2009-12-21 17:29:17 +0000
@@ -81,10 +81,10 @@
81 <div tal:replace="structure potemplate/@@+preferred-chart" />81 <div tal:replace="structure potemplate/@@+preferred-chart" />
8282
83 <div align="right">83 <div align="right">
84 [ <a href="/+editmylanguages">Choose Preferred Languages...</a> 84 [ <a href="/+editmylanguages">Choose preferred languages...</a>
85 &mdash;85 &mdash;
86 <a tal:attributes="href potemplate/fmt:url">86 <a tal:attributes="href potemplate/fmt:url">
87 View Template &amp; All Languages...</a> 87 View template &amp; all languages...</a>
88 ]88 ]
89 </div>89 </div>
9090
9191
=== modified file 'lib/lp/translations/templates/product-translations.pt'
--- lib/lp/translations/templates/product-translations.pt 2009-11-10 02:02:34 +0000
+++ lib/lp/translations/templates/product-translations.pt 2009-12-21 17:29:17 +0000
@@ -2,10 +2,17 @@
2 xmlns="http://www.w3.org/1999/xhtml"2 xmlns="http://www.w3.org/1999/xhtml"
3 xmlns:tal="http://xml.zope.org/namespaces/tal"3 xmlns:tal="http://xml.zope.org/namespaces/tal"
4 xmlns:metal="http://xml.zope.org/namespaces/metal"4 xmlns:metal="http://xml.zope.org/namespaces/metal"
5 metal:use-macro="view/macro:page/main_only"5 metal:use-macro="view/macro:page/main_only">
6>
76
8 <body>7 <body>
8
9 <div metal:fill-slot="head_epilogue">
10 <metal:translations-js
11 use-macro="context/@@+translations-macros/translations-js" />
12 <metal:languages-table-js
13 use-macro="context/@@+translations-macros/languages-table-js" />
14 </div>
15
9 <div metal:fill-slot="main"16 <div metal:fill-slot="main"
10 tal:define="uses_translations view/uses_translations;17 tal:define="uses_translations view/uses_translations;
11 admin_user context/required:launchpad.TranslationsAdmin">18 admin_user context/required:launchpad.TranslationsAdmin">
1219
=== modified file 'lib/lp/translations/templates/productseries-translations-languages.pt'
--- lib/lp/translations/templates/productseries-translations-languages.pt 2009-11-03 05:50:48 +0000
+++ lib/lp/translations/templates/productseries-translations-languages.pt 2009-12-21 17:29:17 +0000
@@ -15,9 +15,18 @@
15 </tr>15 </tr>
16 </thead>16 </thead>
17 <tbody>17 <tbody>
18 <tr tal:repeat="language_stats view/productserieslanguages"18 <tal:loop tal:repeat="language_stats view/productserieslanguages">
19 tal:attributes="class19 <tal:preferred
20 string:stats language-${language_stats/language/code}">20 condition="python: view.isPreferredLanguage(language_stats.language)">
21 <tal:set-class
22 define="global series_language_class string:stats language-${language_stats/language/code} preferred-language" />
23 </tal:preferred>
24 <tal:not-preferred
25 condition="not:python: view.isPreferredLanguage(language_stats.language)">
26 <tal:set-class
27 define="global series_language_class string:stats language-${language_stats/language/code} not-preferred-language" />
28 </tal:not-preferred>
29 <tr tal:attributes="class series_language_class">
21 <td>30 <td>
22 <tal:multiple_pofile condition="not:view/single_potemplate">31 <tal:multiple_pofile condition="not:view/single_potemplate">
23 <a tal:attributes="href language_stats/fmt:url"32 <a tal:attributes="href language_stats/fmt:url"
@@ -68,6 +77,9 @@
68 </tal:block>77 </tal:block>
69 </td>78 </td>
70 </tr>79 </tr>
80 </tal:loop>
71 </tbody>81 </tbody>
72 </table>82 </table>
83 <metal:languages-table-actions
84 use-macro="context/@@+translations-macros/languages-table-actions" />
73</tal:root>85</tal:root>
7486
=== modified file 'lib/lp/translations/templates/productseries-translations.pt'
--- lib/lp/translations/templates/productseries-translations.pt 2009-10-31 12:03:43 +0000
+++ lib/lp/translations/templates/productseries-translations.pt 2009-12-21 17:29:17 +0000
@@ -2,9 +2,17 @@
2 xmlns="http://www.w3.org/1999/xhtml"2 xmlns="http://www.w3.org/1999/xhtml"
3 xmlns:tal="http://xml.zope.org/namespaces/tal"3 xmlns:tal="http://xml.zope.org/namespaces/tal"
4 xmlns:metal="http://xml.zope.org/namespaces/metal"4 xmlns:metal="http://xml.zope.org/namespaces/metal"
5 metal:use-macro="view/macro:page/main_only"5 metal:use-macro="view/macro:page/main_only">
6>6
7 <body>7 <body>
8
9 <div metal:fill-slot="head_epilogue">
10 <metal:translations-js
11 use-macro="context/@@+translations-macros/translations-js" />
12 <metal:languages-table-js
13 use-macro="context/@@+translations-macros/languages-table-js" />
14 </div>
15
8 <div metal:fill-slot="main">16 <div metal:fill-slot="main">
9 <div class="translation-help-links">17 <div class="translation-help-links">
10 <a href="https://help.launchpad.net/Translations"18 <a href="https://help.launchpad.net/Translations"
1119
=== modified file 'lib/lp/translations/templates/translations-macros.pt'
--- lib/lp/translations/templates/translations-macros.pt 2009-12-07 18:42:21 +0000
+++ lib/lp/translations/templates/translations-macros.pt 2009-12-21 17:29:17 +0000
@@ -130,5 +130,41 @@
130</metal:nav-pofile-subpages>130</metal:nav-pofile-subpages>
131131
132132
133<metal:translations-js define-macro="translations-js">
134 <script
135 type="text/javascript"
136 tal:condition="devmode"
137 tal:attributes="src string:${icingroot}/build/translations/translations.js">
138 </script>
139</metal:translations-js>
140
141
142<metal:languages-table-js define-macro="languages-table-js">
143 <script type="text/javascript">
144 LPS.use("node", "translations", function(Y) {
145 Y.on("click", function(e) {
146 Y.translations.toggle_languages_visibility(e);
147 }, "#toggle-languages-visibility");
148 });
149 LPS.use( 'translations', 'event', function(Y) {
150 Y.on('domready', function(e) {
151 Y.translations.initialize_languages_table(Y);
152 });
153 });
154 </script>
155</metal:languages-table-js>
156
157
158<metal:languages-table-actions define-macro="languages-table-actions">
159 <div align="right">
160 [ <a href="/+editmylanguages">Choose preferred languages...</a>
161 <tal:has-preferred condition="view/translatable_languages">&mdash;
162 <a href="#" id="toggle-languages-visibility">
163 View all languages</a>
164 </tal:has-preferred>
165 ]
166 </div>
167</metal:languages-table-actions>
168
133</tal:root>169</tal:root>
134170
135171
=== modified file 'lib/lp/translations/windmill/tests/test_languages.py'
--- lib/lp/translations/windmill/tests/test_languages.py 2009-12-08 11:19:21 +0000
+++ lib/lp/translations/windmill/tests/test_languages.py 2009-12-21 17:29:17 +0000
@@ -6,22 +6,19 @@
6__metaclass__ = type6__metaclass__ = type
7__all__ = []7__all__ = []
88
9import transaction
10
11from windmill.authoring import WindmillTestClient9from windmill.authoring import WindmillTestClient
12from zope.component import getUtility
1310
14from canonical.launchpad.windmill.testing.constants import (11from canonical.launchpad.windmill.testing.constants import (
15 FOR_ELEMENT, PAGE_LOAD, SLEEP)12 PAGE_LOAD, SLEEP)
16from lp.translations.windmill.testing import TranslationsWindmillLayer13from lp.translations.windmill.testing import TranslationsWindmillLayer
17from lp.testing import TestCaseWithFactory14from lp.testing import TestCaseWithFactory
1815
19INPUT_FIELD=(u"//div[contains(@class,'searchform')]"+16INPUT_FIELD = (u"//div[contains(@class,'searchform')]"+
20 u"//input[@id='field.search_lang']")17 u"//input[@id='field.search_lang']")
21FILTER_BUTTON=(u"//div[contains(@class,'searchform')]"+18FILTER_BUTTON = (u"//div[contains(@class,'searchform')]"+
22 u"//input[@value='Filter languages']")19 u"//input[@value='Filter languages']")
23LANGUAGE=u"//a[contains(@class, 'language') and text()='%s']/parent::li"20LANGUAGE = u"//a[contains(@class, 'language') and text()='%s']/parent::li"
24UNSEEN_VALIDATOR='className|unseen'21UNSEEN_VALIDATOR = 'className|unseen'
2522
2623
27class LanguagesFilterTest(TestCaseWithFactory):24class LanguagesFilterTest(TestCaseWithFactory):
@@ -104,4 +101,3 @@
104 u'Mende': True,101 u'Mende': True,
105 u'French': True,102 u'French': True,
106 })103 })
107
108104
=== added file 'lib/lp/translations/windmill/tests/test_serieslanguages.py'
--- lib/lp/translations/windmill/tests/test_serieslanguages.py 1970-01-01 00:00:00 +0000
+++ lib/lp/translations/windmill/tests/test_serieslanguages.py 2009-12-21 17:29:17 +0000
@@ -0,0 +1,83 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Tests for series languages."""
5
6__metaclass__ = type
7__all__ = []
8
9import transaction
10
11from windmill.authoring import WindmillTestClient
12from zope.component import getUtility
13
14from canonical.launchpad.windmill.testing.constants import (
15 PAGE_LOAD, SLEEP)
16from canonical.launchpad.windmill.testing import lpuser
17from canonical.launchpad.windmill.testing.lpuser import login_person
18from lp.translations.windmill.testing import TranslationsWindmillLayer
19from lp.testing import TestCaseWithFactory
20
21LANGUAGE=(u"//table[@id='languagestats']/descendant::a[text()='%s']"
22 u"/parent::td/parent::tr")
23UNSEEN_VALIDATOR='className|unseen'
24
25
26class LanguagesSeriesTest(TestCaseWithFactory):
27 """Tests for serieslanguages."""
28
29 layer = TranslationsWindmillLayer
30
31 def _toggle_languages_visiblity(self):
32 self.client.click(id="toggle-languages-visibility")
33 self.client.waits.sleep(milliseconds=SLEEP)
34
35 def _assert_languages_visible(self, languages):
36 for language, visibility in languages.items():
37 xpath = LANGUAGE % language
38 if visibility:
39 self.client.asserts.assertNotProperty(
40 xpath=xpath, validator=UNSEEN_VALIDATOR)
41 else:
42 self.client.asserts.assertProperty(
43 xpath=xpath, validator=UNSEEN_VALIDATOR)
44
45 def test_serieslanguages_table(self):
46 """Test for filtering preferred languages in serieslanguages table.
47
48 The test cannot fully cover all languages so we just test with a
49 person having Catalan and Spanish as preferred languages.
50 """
51 self.client = WindmillTestClient('SeriesLanguages Tables')
52 start_url = 'http://translations.launchpad.dev:8085/ubuntu'
53 user = lpuser.TRANSLATIONS_ADMIN
54 # Go to the distribution languages page
55 self.client.open(url=start_url)
56 self.client.waits.forPageLoad(timeout=PAGE_LOAD)
57 user.ensure_login(self.client)
58
59 # A link will be displayed for viewing all languages
60 # and only user preferred langauges are displayed
61 self.client.asserts.assertProperty(
62 id=u'toggle-languages-visibility',
63 validator='text|View all languages')
64 self._assert_languages_visible({
65 u'Catalan': True,
66 u'Spanish': True,
67 u'French': False,
68 u'Croatian': False,
69 })
70
71 # Toggle language visibility by clicking the toggle link.
72 self._toggle_languages_visiblity()
73 self.client.asserts.assertProperty(
74 id=u'toggle-languages-visibility',
75 validator='text|View only preferred languages')
76 # All languages should be visible now
77 self._assert_languages_visible({
78 u'Catalan': True,
79 u'Spanish': True,
80 u'French': True,
81 u'Croatian': True,
82 })
83