Index: trunk/extensions/SecurePoll/includes/Page.php |
— | — | @@ -25,22 +25,29 @@ |
26 | 26 | * fallback sequence. |
27 | 27 | */ |
28 | 28 | 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 ) { |
30 | 34 | $userLang = $user->getLanguage(); |
31 | 35 | } else { |
32 | 36 | $userLang = $user->getOption( 'language' ); |
33 | 37 | } |
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 | + } |
40 | 52 | SecurePoll_Entity::setLanguages( $languages ); |
41 | | - |
42 | | - global $wgLang; |
43 | | - $topLang = reset( $languages ); |
44 | | - $wgLang = Language::factory( $topLang ); |
45 | | - wfLoadExtensionMessages( 'SecurePoll', $topLang ); |
46 | 53 | } |
47 | 54 | } |