jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/329635 )

Change subject: Made strings "name" and "badges" translatable
......................................................................


Made strings "name" and "badges" translatable

Strings "name" and "badges" has been made translatable in Item Diff page.

Bug: T111016
Change-Id: I2f53b0e99c72a066599c1117a29541606991930a
---
M repo/i18n/en.json
M repo/i18n/qqq.json
M repo/includes/Diff/DiffView.php
M repo/includes/Diff/EntityDiffVisualizer.php
M repo/tests/phpunit/includes/Diff/EntityDiffVisualizerTest.php
5 files changed, 41 insertions(+), 12 deletions(-)

Approvals:
  Ladsgroup: Looks good to me, approved
  jenkins-bot: Verified
  Thiemo Mättig (WMDE): Looks good to me, but someone else must approve



diff --git a/repo/i18n/en.json b/repo/i18n/en.json
index 89a388f..e320726 100644
--- a/repo/i18n/en.json
+++ b/repo/i18n/en.json
@@ -62,6 +62,8 @@
        "wikibase-diffview-alias": "aliases",
        "wikibase-diffview-description": "description",
        "wikibase-diffview-link": "links",
+       "wikibase-diffview-link-name": "name",
+       "wikibase-diffview-link-badges": "badges",
        "wikibase-sitelink-site-edit-placeholder": "wiki",
        "wikibase-sitelink-page-edit-placeholder": "page",
        "wikibase-alias-edit-placeholder": "enter an alias",
diff --git a/repo/i18n/qqq.json b/repo/i18n/qqq.json
index 018dc7d..a0c5c74 100644
--- a/repo/i18n/qqq.json
+++ b/repo/i18n/qqq.json
@@ -92,7 +92,9 @@
        "wikibase-diffview-label": "Sub heading for label changes in a 
diff.\n{{Identical|Label}}",
        "wikibase-diffview-alias": "Sub heading for alias changes in a 
diff\n{{Identical|Alias}}",
        "wikibase-diffview-description": "Sub heading for description changes 
in a diff.\n{{Identical|Description}}",
-       "wikibase-diffview-link": "Sub heading for link changes in a 
diff.\n{{Identical|Link}}",
+       "wikibase-diffview-link": "Sub heading for sitelink changes in a 
diff.\n{{Identical|Link}}",
+       "wikibase-diffview-link-name": "Sub heading for changes to the name of 
a sitelink in a diff.",
+       "wikibase-diffview-link-badges": "Sub heading for changes to the badges 
of a sitelink in a diff.",
        "wikibase-sitelink-site-edit-placeholder": "[[File:Screenshot 
WikidataRepo 2012-05-13 E.png|right|0x150px]]\nThis is a generic text used as a 
placeholder while defining the site for a new sitelink. See also the Wikidata 
glossary on [[d:Wikidata:Glossary#sitelink|sitelink]].\n{{Identical|Wiki}}",
        "wikibase-sitelink-page-edit-placeholder": "[[File:Screenshot 
WikidataRepo 2012-05-13 E.png|right|0x150px]]\nThis is a generic text used as a 
placeholder while defining the page for a possibly new sitelink. See also the 
Wikidata glossary on 
[[d:Wikidata:Glossary#sitelink|sitelink]].\n{{Identical|Page}}",
        "wikibase-alias-edit-placeholder": "This is a generic placeholder 
message used while editing the list of aliases of an item. It is displayed in 
an empty input box which can be used to define a new alias.",
diff --git a/repo/includes/Diff/DiffView.php b/repo/includes/Diff/DiffView.php
index b59d0ac..317bac5 100644
--- a/repo/includes/Diff/DiffView.php
+++ b/repo/includes/Diff/DiffView.php
@@ -52,6 +52,11 @@
        private $entityIdFormatter;
 
        /**
+        * @var string
+        */
+       private $siteLinkPath;
+
+       /**
         * @since 0.1
         *
         * @param string[] $path
@@ -75,6 +80,8 @@
                if ( !is_null( $contextSource ) ) {
                        $this->setContext( $contextSource );
                }
+
+               $this->siteLinkPath = $this->msg( 'wikibase-diffview-link' 
)->text();
        }
 
        /**
@@ -99,7 +106,17 @@
         */
        private function generateOpHtml( array $path, DiffOp $op ) {
                if ( $op->isAtomic() ) {
-                       $html = $this->generateDiffHeaderHtml( implode( ' / ', 
$path ) );
+                       $localizedPath = $path;
+
+                       if ( $this->isSiteLinkPath( $path ) && isset( $path[2] 
) ) {
+                               $translatedLinkSubPath = $this->msg( 
'wikibase-diffview-link-' . $path[2] );
+
+                               if ( !$translatedLinkSubPath->isDisabled() ) {
+                                       $localizedPath[2] = 
$translatedLinkSubPath->text();
+                               }
+                       }
+
+                       $html = $this->generateDiffHeaderHtml( implode( ' / ', 
$localizedPath ) );
 
                        //TODO: no path, but localized section title
 
@@ -188,7 +205,7 @@
         */
        private function getChangedLine( $tag, $value, array $path ) {
                // @todo: inject a formatter instead of doing special cases 
based on the path here!
-               if ( $path[0] === $this->getLanguage()->getMessage( 
'wikibase-diffview-link' ) ) {
+               if ( $this->isSiteLinkPath( $path ) ) {
                        if ( $path[2] === 'badges' ) {
                                $value = $this->getBadgeLinkElement( $value );
                        } else {
@@ -200,6 +217,15 @@
        }
 
        /**
+        * @param string[] $path
+        *
+        * @return bool
+        */
+       private function isSiteLinkPath( array $path ) {
+               return $path[0] === $this->siteLinkPath && isset( $path[1] );
+       }
+
+       /**
         * @param string $siteId
         * @param string $pageName
         *
diff --git a/repo/includes/Diff/EntityDiffVisualizer.php 
b/repo/includes/Diff/EntityDiffVisualizer.php
index 95a4fa8..4776733 100644
--- a/repo/includes/Diff/EntityDiffVisualizer.php
+++ b/repo/includes/Diff/EntityDiffVisualizer.php
@@ -110,9 +110,9 @@
                        array(),
                        new Diff(
                                array(
-                                       
$this->context->getLanguage()->getMessage( 'wikibase-diffview-label' ) => 
$diff->getLabelsDiff(),
-                                       
$this->context->getLanguage()->getMessage( 'wikibase-diffview-alias' ) => 
$diff->getAliasesDiff(),
-                                       
$this->context->getLanguage()->getMessage( 'wikibase-diffview-description' ) => 
$diff->getDescriptionsDiff(),
+                                       $this->context->msg( 
'wikibase-diffview-label' )->text() => $diff->getLabelsDiff(),
+                                       $this->context->msg( 
'wikibase-diffview-alias' )->text() => $diff->getAliasesDiff(),
+                                       $this->context->msg( 
'wikibase-diffview-description' )->text() => $diff->getDescriptionsDiff(),
                                ),
                                true
                        ),
@@ -133,7 +133,7 @@
                                array(),
                                new Diff(
                                        array(
-                                               
$this->context->getLanguage()->getMessage( 'wikibase-diffview-link' ) => 
$diff->getSiteLinkDiff(),
+                                               $this->context->msg( 
'wikibase-diffview-link' )->text() => $diff->getSiteLinkDiff(),
                                        ),
                                        true
                                ),
diff --git a/repo/tests/phpunit/includes/Diff/EntityDiffVisualizerTest.php 
b/repo/tests/phpunit/includes/Diff/EntityDiffVisualizerTest.php
index b52e7e8..800c989 100644
--- a/repo/tests/phpunit/includes/Diff/EntityDiffVisualizerTest.php
+++ b/repo/tests/phpunit/includes/Diff/EntityDiffVisualizerTest.php
@@ -7,7 +7,6 @@
 use Diff\DiffOp\DiffOpRemove;
 use HashSiteStore;
 use IContextSource;
-use Language;
 use MediaWikiTestCase;
 use Site;
 use Wikibase\DataModel\Services\Diff\EntityDiff;
@@ -90,12 +89,12 @@
         * @return IContextSource
         */
        private function getMockContext() {
-               $en = Language::factory( 'en' );
-
                $mock = $this->getMock( IContextSource::class );
                $mock->expects( $this->any() )
-                       ->method( 'getLanguage' )
-                       ->will( $this->returnValue( $en ) );
+                       ->method( 'msg' )
+                       ->will( $this->returnCallback( function ( $key ) {
+                               return wfMessage( $key )->inLanguage( 'en' );
+                       } ) );
 
                return $mock;
        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I2f53b0e99c72a066599c1117a29541606991930a
Gerrit-PatchSet: 9
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Subins2000 <subins2...@gmail.com>
Gerrit-Reviewer: Aklapper <aklap...@wikimedia.org>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: Hoo man <h...@online.de>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: MtDu <justin.d...@gmail.com>
Gerrit-Reviewer: Siebrand <siebr...@kitano.nl>
Gerrit-Reviewer: Subins2000 <subins2...@gmail.com>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to