r63199 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63198‎ | r63199 | r63200 >
Date:14:05, 3 March 2010
Author:demon
Status:ok (Comments)
Tags:
Comment:
Check for shell locale during setup, add/rename some messages
Modified paths:
  • /branches/new-installer/phase3/includes/installer/Installer.php (modified) (history)
  • /branches/new-installer/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /branches/new-installer/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: branches/new-installer/phase3/maintenance/language/messages.inc
@@ -3205,7 +3205,7 @@
32063206 'config-dir',
32073207 'config-uri',
32083208 'config-no-uri',
3209 - 'config-extension',
 3209+ 'config-file-extension',
32103210 'config-db-type',
32113211 'config-db-host',
32123212 'config-db-host-help',
@@ -3325,13 +3325,15 @@
33263326 'config-cc-again',
33273327 'config-cc-not-chosen',
33283328 'config-advanced-settings',
3329 - 'config-extension',
3330 - 'config-extension-help',
 3329+ 'config-extensions',
 3330+ 'config-extensions-help',
33313331 'config-stage-done',
33323332 'config-install-extensions',
33333333 'config-install-database',
33343334 'config-install-schema',
33353335 'config-install-tables',
 3336+ 'config-install-user',
 3337+ 'config-install-localsettings',
33363338 ),
33373339 );
33383340
Index: branches/new-installer/phase3/includes/installer/Installer.php
@@ -32,6 +32,7 @@
3333 // 'wgDeletedDirectory',
3434 'wgEnableUploads',
3535 'wgLogo',
 36+ 'wgShellLocale'
3637 );
3738
3839 /**
@@ -113,6 +114,7 @@
114115 'envCheckGraphics',
115116 'envCheckPath',
116117 'envCheckExtension',
 118+ 'envCheckShellLocale',
117119 );
118120
119121 /**
@@ -581,9 +583,82 @@
582584 $ext = 'php';
583585 }
584586 $this->setVar( 'wgScriptExtension', ".$ext" );
585 - $this->showMessage( 'config-extension', $ext );
 587+ $this->showMessage( 'config-file-extension', $ext );
586588 }
587589
 590+ function envCheckShellLocale() {
 591+ # Give up now if we're in safe mode or open_basedir
 592+ # It's theoretically possible but tricky to work with
 593+ if ( wfIniGetBool( "safe_mode" ) || ini_get( 'open_basedir' ) || !function_exists( 'exec' ) ) {
 594+ return true;
 595+ }
 596+
 597+ $os = php_uname( 's' );
 598+ $supported = array( 'Linux', 'SunOS', 'HP-UX' ); # Tested these
 599+ if ( !in_array( $os, $supported ) ) {
 600+ return true;
 601+ }
 602+
 603+ # Get a list of available locales
 604+ $lines = $ret = false;
 605+ exec( '/usr/bin/locale -a', $lines, $ret );
 606+ if ( $ret ) {
 607+ return true;
 608+ }
 609+
 610+ $lines = wfArrayMap( 'trim', $lines );
 611+ $candidatesByLocale = array();
 612+ $candidatesByLang = array();
 613+ foreach ( $lines as $line ) {
 614+ if ( $line === '' ) {
 615+ continue;
 616+ }
 617+ if ( !preg_match( '/^([a-zA-Z]+)(_[a-zA-Z]+|)\.(utf8|UTF-8)(@[a-zA-Z_]*|)$/i', $line, $m ) ) {
 618+ continue;
 619+ }
 620+ list( $all, $lang, $territory, $charset, $modifier ) = $m;
 621+ $candidatesByLocale[$m[0]] = $m;
 622+ $candidatesByLang[$lang][] = $m;
 623+ }
 624+
 625+ # Try the current value of LANG
 626+ if ( isset( $candidatesByLocale[ getenv( 'LANG' ) ] ) ) {
 627+ $this->setVar( 'wgShellLocale', getenv( 'LANG' ) );
 628+ $this->showMessage( 'config-shell-locale', getenv( 'LANG' ) );
 629+ return true;
 630+ }
 631+
 632+ # Try the most common ones
 633+ $commonLocales = array( 'en_US.UTF-8', 'en_US.utf8', 'de_DE.UTF-8', 'de_DE.utf8' );
 634+ foreach ( $commonLocales as $commonLocale ) {
 635+ if ( isset( $candidatesByLocale[$commonLocale] ) ) {
 636+ $this->setVar( 'wgShellLocale', $commonLocale );
 637+ $this->showMessage( 'config-shell-locale', $commonLocale );
 638+ return true;
 639+ }
 640+ }
 641+
 642+ # Is there an available locale in the Wiki's language?
 643+ $wikiLang = $this->getVar( 'wgLanguageCode' );
 644+ if ( isset( $candidatesByLang[$wikiLang] ) ) {
 645+ $m = reset( $candidatesByLang[$wikiLang] );
 646+ $this->setVar( 'wgShellLocale', $m[0] );
 647+ $this->showMessage( 'config-shell-locale', $m[0] );
 648+ return true;
 649+ }
 650+
 651+ # Are there any at all?
 652+ if ( count( $candidatesByLocale ) ) {
 653+ $m = reset( $candidatesByLocale );
 654+ $this->setVar( 'wgShellLocale', $m[0] );
 655+ $this->showMessage( 'config-shell-locale', $m[0] );
 656+ return true;
 657+ }
 658+
 659+ # Give up
 660+ return true;
 661+ }
 662+
588663 /**
589664 * Convert wikitext $text to HTML.
590665 *
Index: branches/new-installer/phase3/languages/messages/MessagesEn.php
@@ -4228,7 +4228,8 @@
42294229 'config-dir' => 'Installation directory: <tt>$1</tt>',
42304230 'config-uri' => 'Script URI path: <tt>$1</tt>',
42314231 'config-no-uri' => '<strong>Error:</strong> Could not determine the current URI. Installation aborted.',
4232 -'config-extension' => 'Installing MediaWiki with <tt>$1</tt> file extensions',
 4232+'config-file-extension' => 'Installing MediaWiki with <tt>$1</tt> file extensions',
 4233+'config-shell-locale' => 'Detected shell locale, $1',
42334234
42344235 'config-db-type' => 'Database type:',
42354236 'config-db-host' => 'Database host:',
@@ -4414,8 +4415,8 @@
44154416 'config-cc-not-chosen' => 'Please choose which Creative Commons license you want and click "proceed".',
44164417 'config-advanced-settings' => 'Advanced configuration',
44174418
4418 -'config-extension' => 'Extensions',
4419 -'config-extension-help' => "The following extensions were automatically detected in your extensions directory.\n
 4419+'config-extensions' => 'Extensions',
 4420+'config-extensions-help' => "The following extensions were automatically detected in your extensions directory.\n
44204421 They may require additional configuration, but you can enable them now",
44214422
44224423 'config-stage-done' => 'done',
@@ -4423,6 +4424,8 @@
44244425 'config-install-database' => 'Setting up database',
44254426 'config-install-schema' => 'Generating schema',
44264427 'config-install-tables' => 'Creating tables',
 4428+'config-install-user' => 'Creating admin user',
 4429+'config-install-localsettings' => 'Writing LocalSettings.php',
44274430
44284431 # Special:Version
44294432 'version' => 'Version',

Comments

#Comment by Nikerabbit (talk | contribs)   09:15, 4 March 2010

Can you document envCheckShellLocale, I don't understand what it is doing. Why is it checking the list of all locales? Doesn't it need a codemap to map shell locales to MediaWiki locales?

#Comment by 😂 (talk | contribs)   12:44, 4 March 2010

I can add some documentation for this, yes. It was originally introduced by Tim in r41379 as a fix for bug 14944, if you want more background info.

Status & tagging log