Preferences: Allow only languages with translations in user options
authorFomafix <fomafix@googlemail.com>
Sat, 24 Feb 2018 14:49:46 +0000 (15:49 +0100)
committerNikerabbit <niklas.laxstrom@gmail.com>
Thu, 14 Jun 2018 13:32:47 +0000 (13:32 +0000)
This change allows only language codes with translations for the user
option 'language'. This restrict the selectable values in the
preferences and also prevents setting the user option via API.

With the URL parameter 'uselang' the user interface language can
still set to a language code without translation.

In the current situation this change will remove the following language
codes from the allowed values:
> print '* ' . implode( "\n* ", array_diff(
array_keys( Language::fetchLanguageNames( null, 'mw' ) ),
array_keys( Language::fetchLanguageNames( null, 'mwfile' ) )
) );
* aa
* als
* bat-smg
* be-x-old
* cho
* fiu-vro
* ho
* hz
* kj
* kr
* mh
* mus
* ng
* no
* rn
* roa-rup
* shi-latn
* shi-tfng
* simple
* tum
* uz-cyrl
* uz-latn
* zh-classical
* zh-min-nan
* zh-yue

The change I1dd6fb1f240ce3319b132d0f29f0622fba33e655 ensures that the
deprecated language codes get replaced by the new language codes. The
other untranslated language codes get replaced by the content language
codes when the user loads the preferences.

Bug: T118199
Change-Id: I1382996b031af3fe9f6e1568beeb6376dcbcd217

includes/preferences/DefaultPreferencesFactory.php

index eed4b0d..bf6ab4a 100644 (file)
@@ -406,7 +406,7 @@ class DefaultPreferencesFactory implements PreferencesFactory {
                }
 
                // Language
-               $languages = Language::fetchLanguageNames( null, 'mw' );
+               $languages = Language::fetchLanguageNames( null, 'mwfile' );
                $languageCode = $this->config->get( 'LanguageCode' );
                if ( !array_key_exists( $languageCode, $languages ) ) {
                        $languages[$languageCode] = $languageCode;