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: {{{ al-maisan: ah... that is part of user.ensure_login(self.client) 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.addClass('all-languages-visible'); > + } > +}; > + > + > }, "0.1", { > // "oop" and "event" are required to fix known bugs in YUI, which > // are apparently fixed in a later version. > === 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-17 14:38:47 +0000 > @@ -107,7 +107,6 @@ > else: > self.adminlabel = 'Settings for language packs' > > - > @cachedproperty > def unused_language_packs(self): > unused_language_packs = helpers.shortlist(self.context.language_packs) > @@ -236,6 +235,14 @@ > > return sorted(distroserieslangs, key=lambda a: a.language.englishname) > > + def isPreferredLanguage(self, language): > + # if there are no preferred languages, mark all > + # languages as preferred > + if (len(self.translatable_languages) == 0): > + return True > + else: > + return language in self.translatable_languages > + > @property > def potemplates(self): > return list(self.context.getCurrentTranslationTemplates()) > @@ -245,6 +252,7 @@ > """Is this DistroSeries the translation focus.""" > return self.context.distribution.translation_focus == self.context > > + > class DistroSeriesTranslationsMenu(NavigationMenu): > > usedfor = IDistroSeries > === 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-17 14:38:47 +0000 > @@ -57,6 +57,7 @@ > > class ProductSeriesTranslationsMenuMixIn: > """Translation menu for `IProductSeries`.""" > + > def overview(self): > """Return a link to the overview page.""" > return Link('', 'Overview') > @@ -275,7 +276,7 @@ > warning = ( > "A file could not be uploaded because its " > "name matched multiple existing uploads, for " > - "different templates." ) > + "different templates.") > ul_conflicts = ( > "The conflicting file name was:
" > "" % cgi.escape(conflicts[0])) > @@ -378,6 +379,14 @@ > return sorted(productserieslangs, > key=lambda a: a.language.englishname) > > + def isPreferredLanguage(self, language): > + # if there are no preferred languages, mark all > + # languages as preferred > + if (len(self.translatable_languages) == 0): > + return True > + else: > + return language in self.translatable_languages having isPreferredLanguage() in the code twice is less than ideal but from the conversation on IRC I understood - there was no good place to put it just once and re-use it - this will be addressed when a single serieslanguage view for both product and distro series is introduced (bug #496361). > + > @property > def has_translation_documentation(self): > """Are there translation instructions for this product.""" > @@ -421,8 +430,7 @@ > def change_settings_action(self, action, data): > """Change the translation settings.""" > if (self.context.translations_autoimport_mode != > - data['translations_autoimport_mode'] > - ): > + data['translations_autoimport_mode']): > self.updateContextFromData(data) > # Request an initial upload of translation files. > getUtility(IRosettaUploadJobSource).create( > === 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-17 14:38:47 +0000 > @@ -1,13 +1,19 @@ > - > xmlns="http://www.w3.org/1999/xhtml" > xmlns:tal="http://xml.zope.org/namespaces/tal" > xmlns:metal="http://xml.zope.org/namespaces/metal" > xmlns:i18n="http://xml.zope.org/namespaces/i18n" > - metal:use-macro="view/macro:page/main_only" > -> > + metal:use-macro="view/macro:page/main_only"> > > > + > +
> + + use-macro="context/@@+translations-macros/translations-js" /> > + + use-macro="context/@@+translations-macros/languages-table-js" /> > +
> + >
>