← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/dsp-translations into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/dsp-translations into lp:launchpad.

Commit message:
Give DistributionSourcePackage a basic +translations.

Requested reviews:
  William Grant (wgrant): code

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/dsp-translations/+merge/242736

Currently one can only navigate to a SourcePackage's Translations facet by first visiting a linked ProductSeries or another facet of the SourcePackage. DSP was also unique in that it had no Translations facet despite its subordinate SourcePackage having one.

Since we're about to remove the ability to switch between a SourcePackage's facets using the facet menu, I've added a DistributionSourcePackage:+translations which recommends a SourcePackage:+translations.
-- 
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.
=== modified file 'lib/lp/registry/browser/distributionsourcepackage.py'
--- lib/lp/registry/browser/distributionsourcepackage.py	2014-11-24 01:20:26 +0000
+++ lib/lp/registry/browser/distributionsourcepackage.py	2014-11-25 06:24:32 +0000
@@ -117,6 +117,7 @@
         'overview',
         'branches',
         'bugs',
+        'translations',
         'answers',
         ]
 

=== modified file 'lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt'
--- lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt	2014-11-09 21:58:40 +0000
+++ lib/lp/soyuz/stories/soyuz/xx-distributionsourcepackagerelease-pages.txt	2014-11-25 06:24:32 +0000
@@ -51,7 +51,7 @@
     * Code - http://code.launchpad.dev/ubuntutest/+source/testing-dspr
     * Bugs - http://bugs.launchpad.dev/ubuntutest/+source/testing-dspr
     * Blueprints - not linked
-    * Translations - not linked
+    * Translations - http://translations.launchpad.dev/ubuntutest/+source/testing-dspr
     * Answers - http://answers.launchpad.dev/ubuntutest/+source/testing-dspr
     Main heading: ?testing-dspr? 1.0 source package in ubuntutest
 

=== modified file 'lib/lp/translations/browser/configure.zcml'
--- lib/lp/translations/browser/configure.zcml	2014-07-02 05:40:09 +0000
+++ lib/lp/translations/browser/configure.zcml	2014-11-25 06:24:32 +0000
@@ -475,7 +475,20 @@
             permission="launchpad.AnyPerson"
             template="../templates/translationmessage-suggestions.pt"/>
 
-<!-- SourcePackage translation pages -->
+    <!-- DistributionSourcePackage translation pages -->
+
+    <browser:defaultView
+        for="lp.registry.interfaces.distributionsourcepackage.IDistributionSourcePackage"
+        name="+translations"
+        layer="lp.translations.publisher.TranslationsLayer"/>
+    <browser:page
+        for="lp.registry.interfaces.distributionsourcepackage.IDistributionSourcePackage"
+        name="+translations"
+        class="lp.translations.browser.distributionsourcepackage.DistributionSourcePackageView"
+        permission="zope.Public"
+        template="../templates/distributionsourcepackage-translations.pt"/>
+
+    <!-- SourcePackage translation pages -->
 
     <browser:defaultView
         for="lp.registry.interfaces.sourcepackage.ISourcePackage"

=== added file 'lib/lp/translations/browser/distributionsourcepackage.py'
--- lib/lp/translations/browser/distributionsourcepackage.py	1970-01-01 00:00:00 +0000
+++ lib/lp/translations/browser/distributionsourcepackage.py	2014-11-25 06:24:32 +0000
@@ -0,0 +1,47 @@
+# Copyright 2009-2014 Canonical Ltd.  This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Translations browser views for DistributionSourcePackages."""
+
+__metaclass__ = type
+
+__all__ = [
+    'DistributionSourcePackageView',
+    ]
+
+import operator
+
+from lp.registry.interfaces.series import SeriesStatus
+from lp.services.propertycache import cachedproperty
+from lp.services.webapp.publisher import LaunchpadView
+
+
+class DistributionSourcePackageView(LaunchpadView):
+    """Default DistributionSourcePackage translations view class."""
+
+    @cachedproperty
+    def translation_focus(self):
+        """Return the ISourcePackage where the translators should work.
+
+        If ther isn't a defined focus, we return latest series.
+        """
+        series = (
+            self.context.distribution.translation_focus
+            or self.context.distribution.currentseries)
+        if series is not None:
+            return series.getSourcePackage(self.context.sourcepackagename)
+
+    def secondary_translatable_series(self):
+        """Return a list of ISourcePackages that aren't the translation_focus.
+
+        It only includes the ones that are still supported.
+        """
+        series = [
+            series.getSourcePackage(self.context.sourcepackagename)
+            for series in self.context.distribution.series
+            if (series.status != SeriesStatus.OBSOLETE
+                and (self.translation_focus is None or
+                     self.translation_focus.distroseries != series))]
+
+        return sorted(series, key=operator.attrgetter('distroseries.version'),
+                      reverse=True)

=== added file 'lib/lp/translations/stories/standalone/xx-rosetta-distributionsourcepackage-list.txt'
--- lib/lp/translations/stories/standalone/xx-rosetta-distributionsourcepackage-list.txt	1970-01-01 00:00:00 +0000
+++ lib/lp/translations/stories/standalone/xx-rosetta-distributionsourcepackage-list.txt	2014-11-25 06:24:32 +0000
@@ -0,0 +1,29 @@
+= DistributionSourcePackage translations =
+
+This page directs users to SourcePackage translations pages.
+
+    >>> anon_browser.open(
+    ...     'http://translations.launchpad.dev/ubuntu/+source/evolution')
+    >>> anon_browser.title
+    'Translations : ...evolution...package : Ubuntu'
+
+    >>> content = find_main_content(anon_browser.contents)
+    >>> print extract_text(content.find(attrs='top-portlet'))
+    Launchpad currently recommends translating evolution in Ubuntu Hoary.
+
+The focus' two templates are shown.
+
+    >>> template_names = content.findAll('h2')
+    >>> for name in template_names:
+    ...     print extract_text(name)
+    Template "evolution-2.2" in Ubuntu Hoary package "evolution"
+    Template "man" in Ubuntu Hoary package "evolution"
+    Other versions of evolution in Ubuntu
+
+Other series are also listed.
+
+    >>> for other in content.find(id='distroseries-list').findAll('li'):
+    ...     print extract_text(other)
+    Breezy Badger Autotest (6.6.6)
+    Grumpy (5.10)
+    Warty (4.10)

=== added file 'lib/lp/translations/templates/distributionsourcepackage-translations.pt'
--- lib/lp/translations/templates/distributionsourcepackage-translations.pt	1970-01-01 00:00:00 +0000
+++ lib/lp/translations/templates/distributionsourcepackage-translations.pt	2014-11-25 06:24:32 +0000
@@ -0,0 +1,51 @@
+<html
+  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">
+  <body>
+  <div metal:fill-slot="main">
+    <div class="translation-help-links">
+      <a href="https://help.launchpad.net/Translations";
+         id="link-to-translations-help"
+         >Help for translations
+      </a>
+      <div></div><!-- to clear-up all floats -->
+    </div>
+
+    <tal:translation_focus condition="view/translation_focus"
+                           define="target view/translation_focus">
+
+      <div class="top-portlet">
+          Launchpad currently recommends translating
+          <tal:target replace="structure target/fmt:link/+translations"
+                      >trunk</tal:target>.
+      </div>
+      <div tal:replace="structure view/translation_focus/@@+potlist" />
+    </tal:translation_focus>
+
+    <tal:secondary condition="view/secondary_translatable_series">
+      <h2 tal:condition="view/translation_focus">
+        Other versions of <span tal:replace="context/displayname">Ubuntu</span>
+      </h2>
+
+      <ul id="distroseries-list">
+        <li tal:repeat="sourcepackage view/secondary_translatable_series">
+          <a tal:attributes="href sourcepackage/fmt:url:translations"
+             tal:content="sourcepackage/distroseries/named_version">Hoary (5.04)</a>
+        </li>
+      </ul>
+    </tal:secondary>
+
+    <tal:untranslatable condition="not: view/translation_focus">
+      <p>
+        This package does not have any series to be translated. Once
+        <span tal:replace="context/displayname">Ubuntu</span> has
+        created a distroseries, you will be able to find or create
+        translations for its packages here.
+      </p>
+    </tal:untranslatable>
+</div>
+</body>
+</html>


References