From: Fomafix Date: Sat, 24 Feb 2018 14:49:46 +0000 (+0100) Subject: Preferences: Allow only languages with translations in user options X-Git-Tag: 1.34.0-rc.0~5066^2 X-Git-Url: http://git.cyclocoop.org/%22.%24match%5B1%5D.%22?a=commitdiff_plain;h=aad2e5c38bfea0e2def9b811e4ecda2cd132fc29;p=lhc%2Fweb%2Fwiklou.git Preferences: Allow only languages with translations in user options 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 --- diff --git a/includes/preferences/DefaultPreferencesFactory.php b/includes/preferences/DefaultPreferencesFactory.php index eed4b0d209..bf6ab4a82c 100644 --- a/includes/preferences/DefaultPreferencesFactory.php +++ b/includes/preferences/DefaultPreferencesFactory.php @@ -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;