r49363 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49362‎ | r49363 | r49364 >
Date:13:29, 10 April 2009
Author:tstarling
Status:deferred
Tags:
Comment:
Implemented uselang parameter, use the fallback sequence from the messages files.
Modified paths:
  • /trunk/extensions/SecurePoll/includes/Page.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SecurePoll/includes/Page.php
@@ -25,22 +25,29 @@
2626 * fallback sequence.
2727 */
2828 function initLanguage( $user, $election ) {
29 - if ( $user instanceof SecurePoll_Voter ) {
 29+ global $wgRequest, $wgLang;
 30+ $uselang = $wgRequest->getVal( 'uselang' );
 31+ if ( $uselang !== null ) {
 32+ $userLang = $uselang;
 33+ } elseif ( $user instanceof SecurePoll_Voter ) {
3034 $userLang = $user->getLanguage();
3135 } else {
3236 $userLang = $user->getOption( 'language' );
3337 }
34 - $languages = array(
35 - $userLang,
36 - $election->getLanguage(),
37 - 'en'
38 - );
39 - $languages = array_unique( $languages );
 38+ $wgLang = Language::factory( $userLang );
 39+ wfLoadExtensionMessages( 'SecurePoll', $userLang );
 40+ $languages = array( $userLang );
 41+ $fallback = $userLang;
 42+ while ( $fallback = Language::getFallbackFor( $fallback ) ) {
 43+ $languages[] = $fallback;
 44+ }
 45+ if ( $fallback != $election->getLanguage() ) {
 46+ $fallback = $election->getLanguage();
 47+ $languages[] = $fallback;
 48+ }
 49+ if ( $fallback != 'en' ) {
 50+ $languages[] = 'en';
 51+ }
4052 SecurePoll_Entity::setLanguages( $languages );
41 -
42 - global $wgLang;
43 - $topLang = reset( $languages );
44 - $wgLang = Language::factory( $topLang );
45 - wfLoadExtensionMessages( 'SecurePoll', $topLang );
4653 }
4754 }

Status & tagging log