Amire80 has uploaded a new change for review.

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

Change subject: Fix the behavior of be-tarask and nb in gray interlanguage links
......................................................................

Fix the behavior of be-tarask and nb in gray interlanguage links

* Having 'nb' in Accept-Language was creating a "norsk (bokmal)"
  link even if there already was an no.wikipedia.org link.
  This is fixed by using SiteMapper's getWikiDomainCode().
* Having 'be' was only showing, but not 'be-tarask'.
  The situation with them is similar to having "no" for Norwegian,
  and the solution is the same - to show both domains for this code.

Bug: T113945
Change-Id: I46e9e0ef933f156b5914e3a78af9ddfce6cb19b7
---
M modules/entrypoint/ext.cx.interlanguagelink.js
1 file changed, 15 insertions(+), 8 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/63/247263/1

diff --git a/modules/entrypoint/ext.cx.interlanguagelink.js 
b/modules/entrypoint/ext.cx.interlanguagelink.js
index 1e14da2..e4dc3d6 100644
--- a/modules/entrypoint/ext.cx.interlanguagelink.js
+++ b/modules/entrypoint/ext.cx.interlanguagelink.js
@@ -22,7 +22,7 @@
         * @return {string[]} target languages
         */
        function getSuggestedTargetLanguages() {
-               var i, specialCode, specialCodes, specialCodeIndex,
+               var i, splitCode, splitCodes, specialCodeIndex,
                        uniquePossibleTargetLanguages,
                        acceptLanguages,
                        possibleTargetLanguages = [],
@@ -32,7 +32,8 @@
                possibleTargetLanguages.push( mw.uls.getBrowserLanguage() );
 
                acceptLanguages = mw.uls.getAcceptLanguageList();
-               // Accept language codes can have country extensions like en-US.
+
+                       // Accept language codes can have country extensions 
like en-US.
                // So remove them so that it is like domain code format.
                for ( i = 0; i < acceptLanguages.length; i++ ) {
                        // be-tarask has hyphen in the code
@@ -47,16 +48,18 @@
 
                // Replace possibly non-standard, macro and duplicate language 
codes
                // with normalized counterparts
-               specialCodes = {
-                       // Suggest both varieties of Norwegian when requesting 
macro Norwegian
+               splitCodes = {
+                       // Suggest both varieties of Belarusian when requesting 
'be'
+                       be: [ 'be', 'be-tarask' ],
+                       // Suggest both varieties of Norwegian when requesting 
'no'
                        no: [ 'nb', 'nn' ]
                };
 
-               for ( specialCode in specialCodes ) {
-                       specialCodeIndex = possibleTargetLanguages.indexOf( 
specialCode );
+               for ( splitCode in splitCodes ) {
+                       specialCodeIndex = possibleTargetLanguages.indexOf( 
splitCode );
                        if ( specialCodeIndex > -1 ) {
                                possibleTargetLanguages.splice( 
specialCodeIndex, 1 );
-                               $.merge( possibleTargetLanguages, specialCodes[ 
specialCode ] );
+                               $.merge( possibleTargetLanguages, splitCodes[ 
splitCode ] );
                        }
                }
 
@@ -73,7 +76,11 @@
         * @return {boolean}
         */
        function pageInLanguageExists( code ) {
-               return $( 'li.interlanguage-link.interwiki-' + code ).length 
=== 1;
+               var domainCode;
+
+               domainCode = mw.cx.SiteMapper.prototype.getWikiDomainCode( code 
);
+
+               return $( 'li.interlanguage-link.interwiki-' + domainCode 
).length === 1;
        }
 
        function createCXInterlanguageItem( code ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I46e9e0ef933f156b5914e3a78af9ddfce6cb19b7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Amire80 <[email protected]>

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

Reply via email to