Index: branches/new-installer/phase3/includes/installer/WebInstaller.php |
— | — | @@ -81,6 +81,7 @@ |
82 | 82 | if ( isset( $session['settings'] ) ) { |
83 | 83 | $this->settings = $session['settings'] + $this->settings; |
84 | 84 | } |
| 85 | + $this->setupLanguage(); |
85 | 86 | |
86 | 87 | if ( isset( $session['happyPages'] ) ) { |
87 | 88 | $this->happyPages = $session['happyPages']; |
— | — | @@ -325,6 +326,49 @@ |
326 | 327 | } |
327 | 328 | |
328 | 329 | /** |
| 330 | + * Initializes language-related variables |
| 331 | + */ |
| 332 | + function setupLanguage() { |
| 333 | + global $wgLang, $wgContLang, $wgLanguageCode; |
| 334 | + if ( $this->getSession( 'test' ) === null && !$this->request->wasPosted() ) { |
| 335 | + $wgLanguageCode = $this->getAcceptLanguage(); |
| 336 | + $wgLang = $wgContLang = Language::factory( $wgLanguageCode ); |
| 337 | + $this->setVar( 'wgLanguageCode', $wgLanguageCode ); |
| 338 | + $this->setVar( '_UserLang', $wgLanguageCode ); |
| 339 | + } else { |
| 340 | + $wgLanguageCode = $this->getVar( 'wgLanguageCode' ); |
| 341 | + $wgLang = Language::factory( $this->getVar( '_UserLang' ) ); |
| 342 | + $wgContLang = Language::factory( $wgLanguageCode ); |
| 343 | + } |
| 344 | + } |
| 345 | + |
| 346 | + /** |
| 347 | + * Retrieves MediaWiki language from Accept-Language HTTP header |
| 348 | + */ |
| 349 | + function getAcceptLanguage() { |
| 350 | + global $wgLanguageCode; |
| 351 | + |
| 352 | + $mwLanguages = Language::getLanguageNames(); |
| 353 | + $langs = $_SERVER['HTTP_ACCEPT_LANGUAGE']; |
| 354 | + foreach ( explode( ';', $langs ) as $splitted ) { |
| 355 | + foreach ( explode( ',', $splitted ) as $lang ) { |
| 356 | + $lang = trim( strtolower( $lang ) ); |
| 357 | + if ( $lang == '' || $lang[0] == 'q' ) { |
| 358 | + continue; |
| 359 | + } |
| 360 | + if ( isset( $mwLanguages[$lang] ) ) { |
| 361 | + return $lang; |
| 362 | + } |
| 363 | + $lang = preg_replace( '/^(.*?)(?=-[^-]*)$/', '\\1', $lang ); |
| 364 | + if ( $lang != '' && isset( $mwLanguages[$lang] ) ) { |
| 365 | + return $lang; |
| 366 | + } |
| 367 | + } |
| 368 | + } |
| 369 | + return $wgLanguageCode; |
| 370 | + } |
| 371 | + |
| 372 | + /** |
329 | 373 | * Called by execute() before page output starts, to show a page list |
330 | 374 | */ |
331 | 375 | function startPageWrapper( $currentPageName ) { |
Index: branches/new-installer/phase3/languages/messages/MessagesRu.php |
— | — | @@ -3345,7 +3345,8 @@ |
3346 | 3346 | 'duplicate-defaultsort' => 'Внимание. Ключ сортировки по умолчанию «$2» переопределяет прежний ключ сортировки по умолчанию «$1».', |
3347 | 3347 | |
3348 | 3348 | # Installer |
3349 | | - |
| 3349 | +'config-title' => 'Установка MediaWiki $1', |
| 3350 | +'config-page-language' => 'Язык', |
3350 | 3351 | 'config-admin-default-username' => 'ВикиАдминистратор', |
3351 | 3352 | |
3352 | 3353 | # Special:Version |