Show languages from the Babel box on the user page

Bug: T135371
Change-Id: Ieeaf446326be93a779df3e6bd7a8dca899950a6c
This commit is contained in:
Amire80
2016-09-11 14:59:11 +03:00
parent 411d7834d5
commit 757d28b114
2 changed files with 32 additions and 2 deletions

View File

@@ -350,11 +350,25 @@ class UniversalLanguageSelectorHooks {
// Place request context dependent stuff here
$user = $out->getUser();
$loggedIn = $user->isLoggedIn();
// Do not output accept languages if there is risk it will get cached accross requests
if ( $wgULSAnonCanChangeLanguage || $out->getUser()->isLoggedIn() ) {
if ( $wgULSAnonCanChangeLanguage || $loggedIn ) {
$vars['wgULSAcceptLanguageList'] = array_keys( $out->getRequest()->getAcceptLang() );
}
if ( $loggedIn && class_exists( Babel::class ) ) {
$userLanguageInfo = Babel::getCachedUserLanguageInfo( $user );
// This relies on the fact that Babel levels are 'N' and
// the digits 0 to 5 as strings, and that in reverse
// ASCII order they will be 'N', '5', '4', '3', '2', '1', '0'.
arsort( $userLanguageInfo );
$vars['wgULSBabelLanguages'] = array_keys( $userLanguageInfo );
}
// An optimization to avoid loading all of uls.data just to get the autonym
$langCode = $out->getLanguage()->getCode();
$vars['wgULSCurrentAutonym'] = Language::fetchLanguageName( $langCode );