TTO has uploaded a new change for review.

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

Change subject: Allow interlanguage link prefixes that are not language codes
......................................................................

Allow interlanguage link prefixes that are not language codes

$wgExtraInterlanguageLinkPrefixes holds a list of interwiki prefixes to be
treated as language codes if $wgInterwikiMagic is true.

To set the display text for the interlanguage links generated by this
code, you need to create MediaWiki:Interlanguage-link-foo, where "foo" is
the interwiki prefix. On the WMF cluster, this could be done using the
WikimediaMessages extension.

Bug: 32189
Change-Id: I3d04760e2d9fb3320bb71e3d5ad115eed54a899c
---
M includes/DefaultSettings.php
M includes/SkinTemplate.php
M includes/parser/Parser.php
3 files changed, 33 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/90/111390/1

diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php
index d0ceafc..c08e78c 100644
--- a/includes/DefaultSettings.php
+++ b/includes/DefaultSettings.php
@@ -2485,6 +2485,18 @@
 $wgHideInterlanguageLinks = false;
 
 /**
+ * List of additional interwiki prefixes that should be treated as
+ * interlanguage links (i.e. placed in the sidebar).
+ * Notes:
+ * - This will not do anything unless the prefixes are defined in the interwiki
+ *   map.
+ * - The display text for these custom interlanguage links will be fetched from
+ *   the system message "interlanguage-link-xyz" where xyz is the prefix in
+ *   this array.
+ */
+$wgExtraInterlanguageLinkPrefixes = array();
+
+/**
  * List of language names or overrides for default names in Names.php
  */
 $wgExtraLanguageNames = array();
diff --git a/includes/SkinTemplate.php b/includes/SkinTemplate.php
index 35183ce..d1e78b8 100644
--- a/includes/SkinTemplate.php
+++ b/includes/SkinTemplate.php
@@ -148,8 +148,17 @@
                                $ilLangName = Language::fetchLanguageName( 
$ilInterwikiCode );
 
                                if ( strval( $ilLangName ) === '' ) {
-                                       $ilLangName = $languageLinkText;
+                                       $ilDisplayTextMsg = wfMessage( 
"interlanguage-link-$ilInterwikiCode" )->
+                                               inContentLanguage();
+                                       if ( !$ilDisplayTextMsg->isBlank() ) {
+                                               // Use custom MW message for 
the display text
+                                               $ilLangName = 
$ilDisplayTextMsg->text();
+                                       } else {
+                                               // Last resort: fallback to the 
language link target
+                                               $ilLangName = $languageLinkText;
+                                       }
                                } else {
+                                       // Use the language autonym as display 
text
                                        $ilLangName = 
$this->formatLanguageName( $ilLangName );
                                }
 
@@ -159,9 +168,11 @@
                                        $ilInterwikiCode,
                                        $userLang->getCode()
                                );
-
+                               
                                $languageLinkTitleText = 
$languageLinkTitle->getText();
-                               if ( $languageLinkTitleText === '' ) {
+                               if ( $ilLangLocalName === '' ) {
+                                       $ilTitle = 
$languageLinkTitle->getInterwiki() . ":$languageLinkTitleText";
+                               } elseif ( $languageLinkTitleText === '' ) {
                                        $ilTitle = wfMessage(
                                                
'interlanguage-link-title-langonly',
                                                $ilLangLocalName
diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php
index 9157619..5ac633d 100644
--- a/includes/parser/Parser.php
+++ b/includes/parser/Parser.php
@@ -1835,6 +1835,7 @@
         * @private
         */
        function replaceInternalLinks2( &$s ) {
+               global $wgExtraInterlanguageLinkPrefixes;
                wfProfileIn( __METHOD__ );
 
                wfProfileIn( __METHOD__ . '-setup' );
@@ -2051,9 +2052,12 @@
                        if ( $noforce ) {
                                # Interwikis
                                wfProfileIn( __METHOD__ . "-interwiki" );
-                               if ( $iw && 
$this->mOptions->getInterwikiMagic() && $nottalk && 
Language::fetchLanguageName( $iw, null, 'mw' ) ) {
-                                       // XXX: the above check prevents links 
to sites with identifiers that are not language codes
-
+                               if (
+                                       $iw && 
$this->mOptions->getInterwikiMagic() && $nottalk && (
+                                               Language::fetchLanguageName( 
$iw, null, 'mw' ) ||
+                                               in_array( $iw, 
$wgExtraInterlanguageLinkPrefixes )
+                                       )
+                               ) {
                                        # Bug 24502: filter duplicates
                                        if ( !isset( 
$this->mLangLinkLanguages[$iw] ) ) {
                                                $this->mLangLinkLanguages[$iw] 
= true;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d04760e2d9fb3320bb71e3d5ad115eed54a899c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: TTO <[email protected]>

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

Reply via email to