From: Liangent Date: Sat, 9 Feb 2013 13:21:52 +0000 (+0800) Subject: Set initial language and variant user preferences to user's preferred variant on... X-Git-Tag: 1.31.0-rc.0~20314^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/journal.php?a=commitdiff_plain;h=474ad842af2aa287ccad4e4a14b212a9e50d3028;p=lhc%2Fweb%2Fwiklou.git Set initial language and variant user preferences to user's preferred variant on user registration Change-Id: I7fffe7e96fe5139fe5d023bf9755882dc3efad6e --- diff --git a/includes/specials/SpecialUserlogin.php b/includes/specials/SpecialUserlogin.php index 705f14f2c8..61a042da3b 100644 --- a/includes/specials/SpecialUserlogin.php +++ b/includes/specials/SpecialUserlogin.php @@ -230,7 +230,7 @@ class LoginForm extends SpecialPage { * @return bool */ function addNewAccount() { - global $wgUser, $wgEmailAuthentication, $wgLoginLanguageSelector; + global $wgContLang, $wgUser, $wgEmailAuthentication, $wgLoginLanguageSelector; # Create the account and abort if there's a problem doing so $status = $this->addNewAccountInternal(); @@ -242,10 +242,22 @@ class LoginForm extends SpecialPage { $u = $status->getValue(); - # If we showed up language selection links, and one was in use, be - # smart (and sensible) and save that language as the user's preference - if( $wgLoginLanguageSelector && $this->mLanguage ) { - $u->setOption( 'language', $this->mLanguage ); + # Only save preferences if the user is not creating an account for someone else. + if ( $this->getUser()->isAnon() ) { + # If we showed up language selection links, and one was in use, be + # smart (and sensible) and save that language as the user's preference + if( $wgLoginLanguageSelector && $this->mLanguage ) { + $u->setOption( 'language', $this->mLanguage ); + } else { + + # Otherwise the user's language preference defaults to $wgContLang, + # but it may be better to set it to their preferred $wgContLang variant, + # based on browser preferences or URL parameters. + $u->setOption( 'language', $wgContLang->getPreferredVariant() ); + } + if ( $wgContLang->hasVariants() ) { + $u->setOption( 'variant', $wgContLang->getPreferredVariant() ); + } } $out = $this->getOutput();