jenkins-bot has submitted this change and it was merged.

Change subject: Don't let anonymous users change interface language
......................................................................


Don't let anonymous users change interface language

Language selector is still opened by default

Change-Id: Iee7d83179e71b4546d8f3cd4f6fb053262ce05e2
---
M Resources.php
M i18n/en.json
M i18n/qqq.json
M resources/css/ext.uls.displaysettings.css
M resources/js/ext.uls.displaysettings.js
5 files changed, 50 insertions(+), 2 deletions(-)

Approvals:
  Nikerabbit: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Resources.php b/Resources.php
index e8fab4c..4747205 100644
--- a/Resources.php
+++ b/Resources.php
@@ -22,6 +22,7 @@
                'ext.uls.languagesettings',
                'ext.uls.webfonts',
                'jquery.i18n',
+               'mediawiki.api.parse',
        ),
 ) + $resourcePaths;
 
diff --git a/i18n/en.json b/i18n/en.json
index 9e90a7a..a3b6984 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -19,6 +19,9 @@
 "ext-uls-language-buttons-help": "Change the language of menus. Content 
language will not be affected.",
 "ext-uls-display-settings-font-settings": "Font settings",
 "ext-uls-display-settings-ui-language": "Display language",
+"ext-uls-display-settings-anon-label": "Display language:",
+"ext-uls-display-settings-anon-same-as-content": "English (same as content)",
+"ext-uls-display-settings-anon-log-in-cta": "[[Special:UserLogin|Log in]] to 
select a different language for menus.",
 "ext-uls-webfonts-settings-title": "Download font when needed",
 "ext-uls-webfonts-settings-info": "Webfonts will be downloaded for displaying 
text in special scripts.",
 "ext-uls-webfonts-settings-info-link": "More information",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 63048b1..0646c8b 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -21,6 +21,10 @@
     "ext-uls-language-buttons-help": "Help text that appears above the 
language selection buttons in the Display settings panel.",
     "ext-uls-display-settings-font-settings": "Subsection title for font 
settings",
     "ext-uls-display-settings-ui-language": "Sub section title for selecting 
UI language.\n{{Identical|Display language}}",
+    "ext-uls-display-settings-anon-label": "A label that appears to anonymous 
users before the message 
{{msg-mw|ext-uls-display-settings-anon-same-as-content}}.",
+    "ext-uls-display-settings-anon-same-as-content": "Text that appears to 
anonymous users after the label {{msg-mw|ext-uls-display-settings-anon-label}}.
+Replace \"English\" with the name of your language.",
+    "ext-uls-display-settings-anon-log-in-cta": "A call to action for an 
anonymous user to log in.",
     "ext-uls-webfonts-settings-title": "Short title for enabling webfonts",
     "ext-uls-webfonts-settings-info": "Webfonts will be downloaded for 
displaying text in special scripts.",
     "ext-uls-webfonts-settings-info-link": "More information link text for 
webfonts",
@@ -45,4 +49,4 @@
     "ext-uls-input-enable": "Label for enable input tools button",
     "ext-uls-input-disable-info": "Info text for the disable input tools 
button",
     "ext-uls-input-settings-noime": "Text to be shown when no input methods 
are available for a selected language"
-}
\ No newline at end of file
+}
diff --git a/resources/css/ext.uls.displaysettings.css 
b/resources/css/ext.uls.displaysettings.css
index 85255c8..0480307 100644
--- a/resources/css/ext.uls.displaysettings.css
+++ b/resources/css/ext.uls.displaysettings.css
@@ -100,3 +100,11 @@
        color: #555555;
        font-size: 10pt;
 }
+
+.uls-display-settings-anon-label {
+       font-weight: bold;
+}
+
+#uls-display-settings-anon-log-in-cta {
+       font-size: 10pt;
+}
diff --git a/resources/js/ext.uls.displaysettings.js 
b/resources/js/ext.uls.displaysettings.js
index 661cf1e..d81391f 100644
--- a/resources/js/ext.uls.displaysettings.js
+++ b/resources/js/ext.uls.displaysettings.js
@@ -160,11 +160,43 @@
                 * Prepare the UI language selector
                 */
                prepareLanguages: function () {
-                       var displaySettings = this,
+                       var loginUri, $loginCta,
+                               displaySettings = this,
                                SUGGESTED_LANGUAGES_NUMBER = 3,
+                               anonsAllowed = mw.config.get( 
'wgULSAnonCanChangeLanguage' ),
                                languagesForButtons, $languages, 
suggestedLanguages,
                                lang, i, language, $button;
 
+                       // Don't let anonymous users change interface language
+                       if ( !anonsAllowed && mw.user.isAnon() ) {
+                               loginUri = new mw.Uri();
+                               loginUri.query = {
+                                       title: 'Special:UserLogin'
+                               };
+                               $loginCta = $( '<p>' )
+                                       .attr( 'id', 
'uls-display-settings-anon-log-in-cta' );
+
+                               this.$template.find( 
'.uls-display-settings-language-tab' )
+                                       .empty()
+                                       .append(
+                                               $( '<p>' ).append(
+                                                       $( '<span>' )
+                                                               .addClass( 
'uls-display-settings-anon-label' )
+                                                               .html( $.i18n( 
'ext-uls-display-settings-anon-label' ) + '&#160;' ),
+                                                       $( '<span>' )
+                                                               .text( $.i18n( 
'ext-uls-display-settings-anon-same-as-content' ) )
+                                               ),
+                                               $loginCta
+                                       );
+
+                               new mw.Api().parse( $.i18n( 
'ext-uls-display-settings-anon-log-in-cta' ) )
+                                       .done( function ( parsedCta ) {
+                                               $loginCta.html( parsedCta );
+                                       } );
+
+                               return;
+                       }
+
                        $languages = this.$template.find( 
'div.uls-ui-languages' );
                        suggestedLanguages = this.frequentLanguageList()
                                // Common world languages, for the case that 
there are

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Iee7d83179e71b4546d8f3cd4f6fb053262ce05e2
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/UniversalLanguageSelector
Gerrit-Branch: master
Gerrit-Owner: Amire80 <amir.ahar...@mail.huji.ac.il>
Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com>
Gerrit-Reviewer: Pginer <pgi...@wikimedia.org>
Gerrit-Reviewer: Siebrand <siebr...@wikimedia.org>
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