Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/recife-stats-display 
into lp:~launchpad/launchpad/recife.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers): code


= Recife: Statistics Display =

This changes how we display statistics on certain Translations pages in the 
Recife feature branch.  Before reading this it will be useful to know what we 
mean by "translation side."  there are two "sides" on which a message can be 
translated: Ubuntu and upstream.  The goal of the Recife feature branch is to 
share messages between these two, so that the same messages can be used between 
both as appropriate.

You'll see several changes:

No longer do we show colour-coded status bars with 4 different statuses 
(current, changed, new, untranslated).  These colours try to encode the 
translation status of messages in a POFile, as well as the relationship to 
their translations on the other translation side.  This 4-way breakdown has 
caused the users no end of needless trouble on the one hand: the difference 
between green, blue, and purple is irrelevant for the vast majority of upstream 
users, yet it impresses on them an imaginary need to have their translations 
show up as green.

On the other hand meanwhile, the 4-way breakdown hasn't even been adequate 
since we introduced message sharing.  In the Recife model the two sides become 
meaningful, which also means that the "other side" is not necessarily something 
that a maintainer on "this side" can influence.  There's just no point in 
trying to keep up with all the distinctions there can be between the two sides. 
 Instead, the bars will now indicate just how many messages are translated and 
how many are untranslated on the side you're looking at.

I removed the "Changed" statistics column from the productseries translations 
overview.  This is the column that says how many of the translations differ 
from those on the other side.  The number is primarily of interest on the 
Ubuntu side, where it's easy but often not justified to depart from upstream 
translations.  For upstream maintainers, on the other hand, the number is more 
likely to be a distraction beyond their control: "why do those Ubuntu people 
keep changing my perfectly good translations and why should I care?"  The same 
Ubuntu translations will show up as new suggestions anyway.  However I did not 
make the change for TAL that is used for both Ubuntu and project 
translation—simply too much trouble for now.

Note that the colour-coded bar representing "Changed" is however also removed 
from the Ubuntu displays.  I don't think it's worthwhile to have different 
colour-coding for the two sides, but if we ever decide that it is, it's not 
something we should include in this branch.

To compensate for the loss of detail, I spruced up the statistics fragment on 
the translation-details page.  This used to be a sad old remnant of a Launchpad 
1.0 portlet that we just stuck in there for lack of a better place.  It was 
visually undersized, patently unhelpful, and hopelessly duplicative.  With this 
branch it'll show a bunch of statistics that aren't immediately obvious on the 
overview page, in case you should want them.  (To continue the "lack of a 
better place" theme, I'm not even sure that all the statistics we compute will 
still be shown anywhere apart from this portlet).  I also added percentage 
representations to the absolute numbers.  Those are in the tooltips on the 
bars, but not necessarily discoverable.

Another advantage of having only 2 statuses in the status bars is that we get 
the option of replacing them with progress bars.  That gives us more freedom to 
fit them into the Launchpad style (or in technical terms, "it's not as 
mind-bendingly ugly") and isn't as sensitive to cultural differences.  As I 
recall several of the world's most populous countries have very different 
associations for the colours red and green.

As an afterthought, since we'll probably be printing "in Ubuntu" and "in 
upstream" here and there to indicate the two translation sides, I also gave the 
traits class that keeps properties for the two sides a displayname attribute.

To test this, well, what I did was run all Translations tests.  But you'll 
mostly be interested in the affected ones:
{{{
./bin/test -vvc lp.translations -t xx-productseries-translations -t 
xx-pofile-details -t xx-product-translations -t xx-translationmessage-translate
}}}

We'll Q/A this as part of the Recife feature branch.  There was a bit of lint 
left, all complaints about free-standing comment blocks that I'm not so sure 
aren't perfectly legitimate.


Jeroen
-- 
https://code.launchpad.net/~jtv/launchpad/recife-stats-display/+merge/42483
Your team Launchpad code reviewers is requested to review the proposed merge of 
lp:~jtv/launchpad/recife-stats-display into lp:~launchpad/launchpad/recife.
=== modified file 'lib/lp/translations/browser/translationmessage.py'
--- lib/lp/translations/browser/translationmessage.py	2010-11-25 11:11:34 +0000
+++ lib/lp/translations/browser/translationmessage.py	2010-12-02 14:22:33 +0000
@@ -60,10 +60,7 @@
     )
 from lp.translations.browser.potemplate import POTemplateFacets
 from lp.translations.interfaces.pofile import IPOFileAlternativeLanguage
-from lp.translations.interfaces.side import (
-    ITranslationSideTraitsSet,
-    TranslationSide,
-    )
+from lp.translations.interfaces.side import ITranslationSideTraitsSet
 from lp.translations.interfaces.translationmessage import (
     ITranslationMessage,
     ITranslationMessageSet,
@@ -419,7 +416,6 @@
         return policy.sharesTranslationsWithOtherSide(
             self.user, language, sourcepackage=template.sourcepackage)
 
-
     #
     # API Hooks
     #
@@ -1041,10 +1037,8 @@
             else:
                 self.shared_translationmessage = shared_translationmessage
 
-        if side_traits.side == TranslationSide.UPSTREAM:
-            self.other_title = u"In Ubuntu:"
-        else:
-            self.other_title = u"In Upstream:"
+        self.other_title = "In %s:" % (
+            side_traits.other_side_traits.displayname)
         self.can_confirm_and_dismiss = False
         self.can_dismiss_on_empty = False
         self.can_dismiss_on_plural = False

=== modified file 'lib/lp/translations/interfaces/side.py'
--- lib/lp/translations/interfaces/side.py	2010-08-23 08:41:03 +0000
+++ lib/lp/translations/interfaces/side.py	2010-12-02 14:22:33 +0000
@@ -45,6 +45,8 @@
     flag_name = TextLine(
         title=u"The TranslationMessage flag for this side",
         required=True, readonly=True)
+    displayname = TextLine(
+        title=u"Display name for this side", required=True, readonly=True)
 
     def getCurrentMessage(potemplate, potmsgset, language):
         """Find the current message on this side, if any."""

=== modified file 'lib/lp/translations/model/side.py'
--- lib/lp/translations/model/side.py	2010-11-22 14:27:36 +0000
+++ lib/lp/translations/model/side.py	2010-12-02 14:22:33 +0000
@@ -22,10 +22,11 @@
     """See `ITranslationSideTraits`."""
     implements(ITranslationSideTraits)
 
-    def __init__(self, side, flag_name):
+    def __init__(self, side, flag_name, displayname):
         self.side = side
         self.other_side_traits = None
         self.flag_name = flag_name
+        self.displayname = displayname
 
     def getFlag(self, translationmessage):
         """See `ITranslationSideTraits`."""
@@ -50,9 +51,9 @@
 
     def __init__(self):
         upstream = TranslationSideTraits(
-            TranslationSide.UPSTREAM, 'is_current_upstream')
+            TranslationSide.UPSTREAM, 'is_current_upstream', "upstream")
         ubuntu = TranslationSideTraits(
-            TranslationSide.UBUNTU, 'is_current_ubuntu')
+            TranslationSide.UBUNTU, 'is_current_ubuntu', "Ubuntu")
         ubuntu.other_side_traits = upstream
         upstream.other_side_traits = ubuntu
         self.traits = dict(

=== modified file 'lib/lp/translations/stories/productseries/xx-productseries-translations.txt'
--- lib/lp/translations/stories/productseries/xx-productseries-translations.txt	2010-10-28 13:28:13 +0000
+++ lib/lp/translations/stories/productseries/xx-productseries-translations.txt	2010-12-02 14:22:33 +0000
@@ -22,17 +22,15 @@
     ...         print "No translations."
     ...         return
     ...     language_rows = find_tags_by_class(str(table), 'stats')
-    ...     print "%-25s %13s %13s %13s" % (
-    ...         "Language", "Untranslated", "Unreviewed", "Changed")
+    ...     print "%-25s %13s %13s" % (
+    ...         "Language", "Untranslated", "Unreviewed")
     ...     for row in language_rows:
     ...         cols = row.findAll('td')
     ...         language = extract_text(cols[0])
     ...         untranslated = extract_text(cols[2])
     ...         unreviewed = extract_text(cols[3])
-    ...         changed = extract_text(cols[4])
-    ...         print "%-25s %13d %13d %13d" % (
-    ...             language,
-    ...             int(untranslated), int(unreviewed), int(changed))
+    ...         print "%-25s %13d %13d" % (
+    ...             language, int(untranslated), int(unreviewed))
 
 When there are no translatable templates, series is considered as not
 being set up for translation.
@@ -80,8 +78,8 @@
 
     >>> browser.open(frobnicator_trunk_url)
     >>> print_language_stats(browser)
-    Language                   Untranslated    Unreviewed       Changed
-    Serbian                               6             5             2
+    Language                   Untranslated    Unreviewed
+    Serbian                               6             5
 
 Since there is only one template, language link directly to PO file
 pages.
@@ -104,8 +102,8 @@
 
     >>> browser.open(frobnicator_trunk_url)
     >>> print_language_stats(browser)
-    Language                   Untranslated    Unreviewed       Changed
-    Serbian                              11             5             2
+    Language                   Untranslated    Unreviewed
+    Serbian                              11             5
 
 With more than one template, link points to a product series per-language
 translations page.

=== modified file 'lib/lp/translations/stories/standalone/xx-pofile-details.txt'
--- lib/lp/translations/stories/standalone/xx-pofile-details.txt	2010-03-23 13:13:51 +0000
+++ lib/lp/translations/stories/standalone/xx-pofile-details.txt	2010-12-02 14:22:33 +0000
@@ -4,6 +4,7 @@
 Each translation file has an overview page which shows the list of
 contributors.
 
+    >>> from lp.testing.sampledata import ADMIN_EMAIL
     >>> anon_browser.open(
     ...     'http://translations.launchpad.dev/evolution/trunk/+pots/'
     ...     'evolution-2.2/es/+details')
@@ -139,7 +140,7 @@
     >>> from canonical.launchpad.interfaces.launchpad import (
     ...     ILaunchpadCelebrities)
 
-    >>> login("[email protected]")
+    >>> login(ADMIN_EMAIL)
     >>> ubuntu = getUtility(ILaunchpadCelebrities).ubuntu
     >>> hoary = ubuntu.getSeries('hoary')
     >>> translator = factory.makePerson(displayname="Poly Glot")
@@ -173,3 +174,30 @@
 
     >>> u'Mere Pere' in main_text
     False
+
+
+Statistics
+----------
+
+A POFile's details page shows translation statistics.
+
+    >>> login(ADMIN_EMAIL)
+    >>> naked_pofile = removeSecurityProxy(factory.makePOFile())
+    >>> naked_pofile.potemplate.messagecount = 10
+    >>> naked_pofile.untranslated = 3
+    >>> naked_pofile.currentcount = 4
+    >>> naked_pofile.updatescount = 2
+    >>> naked_pofile.rosettacount = 1 + naked_pofile.updatescount
+    >>> pofile_url = canonical_url(naked_pofile) + '/+details'
+    >>> logout()
+
+    >>> browser.open(pofile_url)
+    >>> stats_portlet = find_tag_by_id(browser.contents, 'portlet-stats')
+    >>> print extract_text(stats_portlet)
+    Statistics
+    Messages: 10
+    Translated: 7 (70.0%)
+    Untranslated: 3 (30.0%)
+    Shared between Ubuntu and upstream: 4 (40.0%)
+    Translated differently between Ubuntu and upstream: 2 (20.0%)
+    Only translated on this side: 1 (10.0%)

=== modified file 'lib/lp/translations/stories/standalone/xx-product-translations.txt'
--- lib/lp/translations/stories/standalone/xx-product-translations.txt	2010-10-06 20:49:58 +0000
+++ lib/lp/translations/stories/standalone/xx-product-translations.txt	2010-12-02 14:22:33 +0000
@@ -20,24 +20,22 @@
     ...         print "No translations."
     ...         return
     ...     language_rows = find_tags_by_class(str(table), 'stats')
-    ...     print "%-25s %13s %13s %13s" % (
-    ...         "Language", "Untranslated", "Unreviewed", "Changed")
+    ...     print "%-25s %13s %13s" % (
+    ...         "Language", "Untranslated", "Unreviewed")
     ...     for row in language_rows:
     ...         cols = row.findAll('td')
     ...         language = extract_text(cols[0])
     ...         untranslated = extract_text(cols[2])
     ...         unreviewed = extract_text(cols[3])
-    ...         changed = extract_text(cols[4])
-    ...         print "%-25s %13d %13d %13d" % (
-    ...             language,
-    ...             int(untranslated), int(unreviewed), int(changed))
+    ...         print "%-25s %13d %13d" % (
+    ...             language, int(untranslated), int(unreviewed))
 
 We even have a language chart table.
 
     >>> print_language_stats(anon_browser)
-    Language                   Untranslated    Unreviewed       Changed
-    Portuguese (Brazil)                  25             0             0
-    Spanish                              22             2             0
+    Language                   Untranslated    Unreviewed
+    Portuguese (Brazil)                  25             0
+    Spanish                              22             2
 
 If a product is not set up for translations in Launchpad, and you are its
 registrant or an admin, the Translations page suggests that you set it up for
@@ -50,11 +48,12 @@
     ...     find_tag_by_id(
     ...         registrant.contents, 'not-translated-in-launchpad'))
     Launchpad does not know where gnomebaker translates its messages.
-    
+
     >>> print extract_text(
     ...     find_tag_by_id(
     ...         registrant.contents, 'translations-explanation'))
-    Launchpad allows communities to translate projects using imports or a branch. 
+    Launchpad allows communities to translate projects using imports or a
+    branch.
     Getting started with translating your project in Launchpad
     Configure translations
 
@@ -165,7 +164,7 @@
     <...
     ...Translation overview...
     >>> print_language_stats(anon_browser)
-    Language                   Untranslated    Unreviewed       Changed
+    Language                   Untranslated    Unreviewed
 
 
 Translation recommendation

=== modified file 'lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt'
--- lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt	2010-11-24 15:09:50 +0000
+++ lib/lp/translations/stories/standalone/xx-translationmessage-translate.txt	2010-12-02 14:22:33 +0000
@@ -527,7 +527,7 @@
     ...              '+source/evolution/+pots/evolution-2.2/es/5/+translate')
     >>> packaged = find_tag_by_id(browser.contents, 'msgset_134_other')
     >>> print extract_text(packaged)
-    In Upstream: tarjetas
+    In upstream: tarjetas
 
 First, we look for an existing imported translation in evolution PO file
 in Ubuntu Hoary.  We can't modify "imported" messages through web UI, so

=== modified file 'lib/lp/translations/templates/pofile-portlet-stats.pt'
--- lib/lp/translations/templates/pofile-portlet-stats.pt	2009-07-17 17:59:07 +0000
+++ lib/lp/translations/templates/pofile-portlet-stats.pt	2010-12-02 14:22:33 +0000
@@ -15,9 +15,26 @@
             <b>Messages:</b>
             <span tal:replace="context/messageCount">N</span>
             <br/>
-            <b>To do:</b>
+            <b>Translated:</b>
+            <span tal:replace="context/translatedCount">N</span>
+            (<span tal:replace="context/translatedPercentage">N</span>%)
+            <br/>
+            <b>Untranslated:</b>
             <span tal:replace="context/untranslatedCount">N</span>
+            (<span tal:replace="context/untranslatedPercentage">N</span>%)
+            <br/>
+            <b>Shared between Ubuntu and upstream:</b>
+            <span tal:replace="context/currentCount">N</span>
+            (<span tal:replace="context/currentPercentage">N</span>%)
             <br />
+            <b>Translated differently between Ubuntu and upstream:</b>
+            <span tal:replace="context/updatesCount">N</span>
+            (<span tal:replace="context/updatesPercentage">N</span>%)
+            <br/>
+            <b>Only translated on this side:</b>
+            <span tal:replace="context/newCount">N</span>
+            (<span tal:replace="context/newPercentage">N</span>%)
+            <br/>
             <tal:block condition="context/lasttranslator">
                 <b>Latest contributor:</b>
                 <br />

=== modified file 'lib/lp/translations/templates/productseries-translations-languages.pt'
--- lib/lp/translations/templates/productseries-translations-languages.pt	2009-12-16 15:21:36 +0000
+++ lib/lp/translations/templates/productseries-translations-languages.pt	2010-12-02 14:22:33 +0000
@@ -10,7 +10,6 @@
             <th>Status</th>
             <th>Untranslated</th>
             <th>Needs review</th>
-            <th>Changed</th>
             <th>Last Changed</th>
           </tr>
         </thead>
@@ -54,11 +53,6 @@
             </td>
             <td>
               <span class="sortkey"
-                    tal:content="language_stats/updatesCount">0</span>
-              <tal:value content="language_stats/updatesCount" />
-            </td>
-            <td>
-              <span class="sortkey"
                 tal:condition="language_stats/last_changed_date"
                 tal:content="language_stats/last_changed_date/fmt:datetime">
                 time sort key

=== modified file 'lib/lp/translations/templates/rosetta-status-legend.pt'
--- lib/lp/translations/templates/rosetta-status-legend.pt	2010-03-23 15:05:01 +0000
+++ lib/lp/translations/templates/rosetta-status-legend.pt	2010-12-02 14:22:33 +0000
@@ -11,23 +11,7 @@
       src="/@@/green-bar"
       style="height: 1em; width: 2em;"
     />
-    Translation unchanged since last synchronized
-  </div>
-  <div>
-    <img
-      alt="&#8220;Changed&#8221; means"
-      src="/@@/blue-bar"
-      style="height: 1em; width: 2em;"
-    />
-    Changed in Ubuntu
-  </div>
-  <div>
-    <img
-      alt="&#8220;new&#8221; means"
-      src="/@@/purple-bar"
-      style="height: 1em; width: 2em;"
-    />
-    Newly translated in Launchpad
+    Translated
   </div>
   <div>
     <img

=== modified file 'lib/lp/translations/templates/rosettastats-barchart.pt'
--- lib/lp/translations/templates/rosettastats-barchart.pt	2009-07-17 17:59:07 +0000
+++ lib/lp/translations/templates/rosettastats-barchart.pt	2010-12-02 14:22:33 +0000
@@ -9,30 +9,14 @@
   tal:condition="not: context/messageCount"
   src="/@@/red-bar" height="10" width="100" style="height: 1em;" />
 <img
-  tal:condition="context/currentCount"
+  tal:condition="context/translatedCount"
   tal:attributes="
-    alt string: ${context/currentPercentage}% published, ;
-    title string:Unchanged: ${context/currentPercentage} %;
-    width context/currentPercentage;
+    alt string: ${context/translatedPercentage}% translated ;
+    title string:Translated: ${context/translatedPercentage} %;
+    width context/translatedPercentage;
   "
   height="10" src="/@@/green-bar" style="height: 1em;"
 /><img
-  tal:condition="context/updatesCount"
-  tal:attributes="
-    alt string: ${context/updatesPercentage}% changed, ;
-    width context/updatesPercentage;
-    title string: Changed: ${context/updatesPercentage} %
-  "
-  height="10" src="/@@/blue-bar" style="height: 1em;"
-/><img
-  tal:condition="context/newCount"
-  tal:attributes="
-    alt string: ${context/newPercentage}% new, ;
-    width context/newPercentage;
-    title string: New: ${context/newPercentage} %
-  "
-  height="10" src="/@@/purple-bar" style="height: 1em;"
-/><img
   tal:condition="context/untranslatedCount"
   tal:attributes="
     alt string: ${context/untranslatedPercentage}% untranslated;

_______________________________________________
Mailing list: https://launchpad.net/~launchpad-reviewers
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~launchpad-reviewers
More help   : https://help.launchpad.net/ListHelp

Reply via email to