Nemo bis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/118959

Change subject: Revert "Do not display fuzzy translations on translation pages"
......................................................................

Revert "Do not display fuzzy translations on translation pages"

This reverts commit daa576affc38dd0e9179d97b774a36df92f60edf.

Change-Id: I43aa0ec577d2fcd40418348ee430f7594935651d
---
M PageTranslation.i18n.php
M resources/css/ext.translate.css
M tag/PageTranslationHooks.php
M tag/RenderJob.php
M tag/TPParse.php
5 files changed, 33 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/59/118959/1

diff --git a/PageTranslation.i18n.php b/PageTranslation.i18n.php
index f53b898..468c450 100644
--- a/PageTranslation.i18n.php
+++ b/PageTranslation.i18n.php
@@ -89,6 +89,7 @@
        'translate-tag-markthisagain' => 'This page has <span 
class="plainlinks">[$1 changes]</span> since it was last <span 
class="plainlinks">[$2 marked for translation]</span>.',
        'translate-tag-hasnew' => 'This page contains <span 
class="plainlinks">[$1 changes]</span> which are not marked for translation.',
        'tpt-translation-intro' => 'This page is a <span class="plainlinks">[$1 
translated version]</span> of a page [[$2]] and the translation is $3% 
complete.',
+       'tpt-translation-intro-fuzzy' => 'Outdated translations are marked like 
this.',
 
        'tpt-languages-legend' => 'Other languages:',
        'tpt-languages-separator' => '&#160;•&#160;',
diff --git a/resources/css/ext.translate.css b/resources/css/ext.translate.css
index a321463..b88614d 100644
--- a/resources/css/ext.translate.css
+++ b/resources/css/ext.translate.css
@@ -1,3 +1,7 @@
+.mw-translate-fuzzy {
+       background-color: #FDD;
+}
+
 .mw-translate-page-info {
        font-size: x-small;
        text-align: center;
diff --git a/tag/PageTranslationHooks.php b/tag/PageTranslationHooks.php
index 3084bd4..5423138 100644
--- a/tag/PageTranslationHooks.php
+++ b/tag/PageTranslationHooks.php
@@ -739,6 +739,17 @@
                $wrap = '<div class="mw-translate-page-info">$1</div>';
                $wgOut->wrapWikiMsg( $wrap, array( 'tpt-translation-intro', 
$url, $titleText, $per ) );
 
+               if ( floor( $per ) < 100 ) {
+                       $groupId = $page->getMessageGroup()->getId();
+                       $stats = MessageGroupStats::forItem( $groupId, $code );
+                       $fuzzy = $stats[MessageGroupStats::FUZZY];
+                       if ( $fuzzy ) {
+                               // Only show if there is fuzzy messages
+                               $wrap = '<div class="mw-translate-page-info 
mw-translate-fuzzy">$1</div>';
+                               $wgOut->wrapWikiMsg( $wrap, array( 
'tpt-translation-intro-fuzzy' ) );
+                       }
+               }
+
                $wgOut->addHTML( '<hr />' );
        }
 
diff --git a/tag/RenderJob.php b/tag/RenderJob.php
index d26cd99..d428d04 100644
--- a/tag/RenderJob.php
+++ b/tag/RenderJob.php
@@ -49,6 +49,7 @@
 
                $group = $page->getMessageGroup();
                $collection = $group->initCollection( $code );
+               $collection->loadTranslations( DB_MASTER );
 
                $text = $page->getParse()->getTranslationPageText( $collection 
);
 
diff --git a/tag/TPParse.php b/tag/TPParse.php
index 84a298d..0200e46 100644
--- a/tag/TPParse.php
+++ b/tag/TPParse.php
@@ -165,8 +165,10 @@
        }
 
        /**
-        * Returns translation page with all possible translations replaced in
-        * and ugly translation tags removed.
+        * Returns translation page with all possible translations replaced in, 
ugly
+        * translation tags removed and outdated translation marked with a class
+        * mw-translate-fuzzy.
+        * @todo The class marking has to be more intelligent with span&div use.
         * @param MessageCollection $collection Collection that holds 
translated messages.
         * @return string Whole page as wikitext.
         */
@@ -177,8 +179,8 @@
                $prefix = $this->title->getPrefixedDBKey() . '/';
 
                if ( $collection instanceof MessageCollection ) {
-                       $collection->filter( 'translated', false );
-                       $collection->loadTranslations( DB_MASTER );
+                       $collection->filter( 'hastranslation', false );
+                       $collection->loadTranslations();
                }
 
                foreach ( $this->sections as $ph => $s ) {
@@ -189,7 +191,16 @@
                                 * @var TMessage $msg
                                 */
                                $msg = $collection[$prefix . $s->id];
-                               $sectiontext = $msg->translation();
+                               $translation = $msg->translation();
+
+                               if ( $translation !== null ) {
+                                       // Ideally we should not have fuzzy 
here, but old texts do
+                                       $sectiontext = str_replace( 
TRANSLATE_FUZZY, '', $translation );
+
+                                       if ( $msg->hasTag( 'fuzzy' ) ) {
+                                               $sectiontext = "<span 
class=\"mw-translate-fuzzy\">\n$sectiontext\n</span>";
+                                       }
+                               }
                        }
 
                        // Use the original text if no translation is available

-- 
To view, visit https://gerrit.wikimedia.org/r/118959
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I43aa0ec577d2fcd40418348ee430f7594935651d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Nemo bis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to