diff --git a/UniversalLanguageSelector.hooks.php b/UniversalLanguageSelector.hooks.php index 191818ba..b14ad2ae 100644 --- a/UniversalLanguageSelector.hooks.php +++ b/UniversalLanguageSelector.hooks.php @@ -75,7 +75,8 @@ class UniversalLanguageSelectorHooks { if ( $wgULSCompactLanguageLinksBetaFeature === false ) { // Compact language links is a default feature in this wiki. - return true; + // Check user preference + return $user->getBoolOption( 'compact-language-links' ); } return false; @@ -340,6 +341,8 @@ class UniversalLanguageSelectorHooks { } public static function onGetPreferences( $user, &$preferences ) { + global $wgULSCompactLanguageLinksBetaFeature; + $preferences['uls-preferences'] = [ 'type' => 'api', ]; @@ -354,6 +357,14 @@ class UniversalLanguageSelectorHooks { // showing the link when javascript is disabled. ]; + if ( $wgULSCompactLanguageLinksBetaFeature === false ) { + $preferences['compact-language-links'] = [ + 'type' => 'check', + 'section' => 'rendering/languages', + 'label-message' => 'ext-uls-compact-language-links-preference' + ]; + } + return true; } diff --git a/extension.json b/extension.json index 54988e23..19396282 100644 --- a/extension.json +++ b/extension.json @@ -48,7 +48,8 @@ "UniversalLanguageSelectorHooks": "UniversalLanguageSelector.hooks.php" }, "DefaultUserOptions": { - "uls-preferences": "" + "uls-preferences": "", + "compact-language-links": true }, "config": { "@ULSGeoService": "ULS can use geolocation services to suggest languages based on the country the user is vising from. Setting this to false will prevent builtin geolocation from being used. You can provide your own geolocation by setting window.Geo to object which has key \"country_code\" or \"country\". If set to true, it will query Wikimedia's geoip service. The service should return jsonp that uses the supplied callback parameter.", diff --git a/i18n/en.json b/i18n/en.json index e54324a0..92ea7d31 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -70,5 +70,7 @@ "apihelp-ulslocalization-description": "Get the localization of ULS in the given language.", "apihelp-ulslocalization-param-language": "Language code.", "apihelp-ulslocalization-example-1": "Get Tamil localization", - "apihelp-ulslocalization-example-2": "Get Hindi localization" + "apihelp-ulslocalization-example-2": "Get Hindi localization", + "prefs-languages": "Languages", + "ext-uls-compact-language-links-preference": "Use a compact language list, with languages relevant to you." } diff --git a/i18n/qqq.json b/i18n/qqq.json index d4c32eab..0caf13f9 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -72,5 +72,7 @@ "apihelp-ulslocalization-description": "{{doc-apihelp-description|ulslocalization}}", "apihelp-ulslocalization-param-language": "{{doc-apihelp-param|ulslocalization|language}}\n{{Identical|Language code}}", "apihelp-ulslocalization-example-1": "{{doc-apihelp-example|ulslocalization}}", - "apihelp-ulslocalization-example-2": "{{doc-apihelp-example|ulslocalization}}" + "apihelp-ulslocalization-example-2": "{{doc-apihelp-example|ulslocalization}}", + "prefs-languages": "Field set legend for user preferences regarding display of language lists", + "ext-uls-compact-language-links-preference": "Label for compact language links user preference" }