Localize time zone regions in Special:Preferences
authorRaimond Spekking <raymond@users.mediawiki.org>
Tue, 10 Feb 2009 16:19:34 +0000 (16:19 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Tue, 10 Feb 2009 16:19:34 +0000 (16:19 +0000)
RELEASE-NOTES
includes/specials/SpecialPreferences.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index b99c334..2b34bc8 100644 (file)
@@ -93,6 +93,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   "mw-line-odd" and "mw-line-even" to make styling using css possible.
 * (bug 17311) Add a note beside the gender selection menu to tell users that
   this information will be public
+* Localize time zone regions in Special:Preferences
 
 === Bug fixes in 1.15 ===
 * (bug 16968) Special:Upload no longer throws useless warnings.
index 72bab7c..84654e1 100644 (file)
@@ -1027,26 +1027,54 @@ class PreferencesForm {
                        'onchange' => 'javascript:updateTimezoneSelection(false)' ) );
                $opt .= Xml::option( wfMsg( 'timezoneuseserverdefault' ), "System|$wgLocalTZoffset", $this->mTimeZone === "System|$wgLocalTZoffset" );
                $opt .= Xml::option( wfMsg( 'timezoneuseoffset' ), 'Offset', $this->mTimeZone === 'Offset' );
+
                if ( function_exists( 'timezone_identifiers_list' ) ) {
-                       $optgroup = '';
+                       # Read timezone list
                        $tzs = timezone_identifiers_list();
                        sort( $tzs );
-                       $selZone = explode( '|', $this->mTimeZone, 3);
+
+                       # Precache localized region names
+                       $tzRegions = array();
+                       $tzRegions['Africa'] = wfMsg( 'timezoneregion-africa' );
+                       $tzRegions['America'] = wfMsg( 'timezoneregion-america' );
+                       $tzRegions['Antarctica'] = wfMsg( 'timezoneregion-antarctica' );
+                       $tzRegions['Arctic'] = wfMsg( 'timezoneregion-arctic' );
+                       $tzRegions['Asia'] = wfMsg( 'timezoneregion-asia' );
+                       $tzRegions['Atlantic'] = wfMsg( 'timezoneregion-atlantic' );
+                       $tzRegions['Australia'] = wfMsg( 'timezoneregion-australia' );
+                       $tzRegions['Europe'] = wfMsg( 'timezoneregion-europe' );
+                       $tzRegions['Indian'] = wfMsg( 'timezoneregion-indian' );
+                       $tzRegions['Pacific'] = wfMsg( 'timezoneregion-pacific' );
+                       asort( $tzRegions );
+
+                       $selZone = explode( '|', $this->mTimeZone, 3 );
                        $selZone = ( $selZone[0] == 'ZoneInfo' ) ? $selZone[2] : null;
                        $now = date_create( 'now' );
+                       $optgroup = '';
+
                        foreach ( $tzs as $tz ) {
                                $z = explode( '/', $tz, 2 );
+
                                # timezone_identifiers_list() returns a number of
                                # backwards-compatibility entries. This filters them out of the 
                                # list presented to the user.
-                               if ( count( $z ) != 2 || !in_array( $z[0], array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific' ) ) ) continue;
+                               if ( count( $z ) != 2 || !array_key_exists( $z[0], $tzRegions ) )
+                                       continue;
+
+                               # Localize region
+                               $z[0] = $tzRegions[$z[0]];
+
+                               # Create region groups
                                if ( $optgroup != $z[0] ) {
-                                       if ( $optgroup !== '' ) $opt .= Xml::closeElement( 'optgroup' );
+                                       if ( $optgroup !== '' ) {
+                                               $opt .= Xml::closeElement( 'optgroup' );
+                                       }
                                        $optgroup = $z[0];
-                                       $opt .= Xml::openElement( 'optgroup', array( 'label' => $z[0] ) );
+                                       $opt .= Xml::openElement( 'optgroup', array( 'label' => $z[0] ) ) . "\n";
                                }
+
                                $minDiff = floor( timezone_offset_get( timezone_open( $tz ), $now ) / 60 );
-                               $opt .= Xml::option( str_replace( '_', ' ', $tz ), "ZoneInfo|$minDiff|$tz", $selZone === $tz, array( 'label' => $z[1] ) );
+                               $opt .= Xml::option( str_replace( '_', ' ', $z[0] . '/' . $z[1] ), "ZoneInfo|$minDiff|$tz", $selZone === $tz, array( 'label' => $z[1] ) ) . "\n";
                        }
                        if ( $optgroup !== '' ) $opt .= Xml::closeElement( 'optgroup' );
                }
index 39f9d6d..88f2061 100644 (file)
@@ -1586,6 +1586,16 @@ please see math/README to configure.',
 'timezoneoffset'            => 'Offset¹:',
 'servertime'                => 'Server time:',
 'guesstimezone'             => 'Fill in from browser',
+'timezoneregion-africa'     => 'Africa',
+'timezoneregion-america'    => 'America',
+'timezoneregion-antarctica' => 'Antarctica',
+'timezoneregion-arctic'     => 'Arktic',
+'timezoneregion-asia'       => 'Asia',
+'timezoneregion-atlantic'   => 'Atlantic Ocean',
+'timezoneregion-australia'  => 'Australia',
+'timezoneregion-europe'     => 'Europe',
+'timezoneregion-indian'     => 'Indian Ocean',
+'timezoneregion-pacific'    => 'Pacific Ocean',
 'allowemail'                => 'Enable e-mail from other users',
 'prefs-searchoptions'       => 'Search options',
 'prefs-namespaces'          => 'Namespaces',
index 7c6f5a0..0172777 100644 (file)
@@ -907,6 +907,16 @@ $wgMessageStructure = array(
                'timezoneoffset',
                'servertime',
                'guesstimezone',
+               'timezoneregion-africa',
+               'timezoneregion-america',
+               'timezoneregion-antarctica',
+               'timezoneregion-arctic',
+               'timezoneregion-asia',
+               'timezoneregion-atlantic',
+               'timezoneregion-australia',
+               'timezoneregion-europe',
+               'timezoneregion-indian',
+               'timezoneregion-pacific',
                'allowemail',
                'prefs-searchoptions',
                'prefs-namespaces',