From f6c0a3111b3f3d5b9c68d9074e5973d55e964f19 Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Tue, 10 Feb 2009 16:19:34 +0000 Subject: [PATCH] Localize time zone regions in Special:Preferences --- RELEASE-NOTES | 1 + includes/specials/SpecialPreferences.php | 40 ++++++++++++++++++++---- languages/messages/MessagesEn.php | 10 ++++++ maintenance/language/messages.inc | 10 ++++++ 4 files changed, 55 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b99c334fc3..2b34bc89c0 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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. diff --git a/includes/specials/SpecialPreferences.php b/includes/specials/SpecialPreferences.php index 72bab7c854..84654e1437 100644 --- a/includes/specials/SpecialPreferences.php +++ b/includes/specials/SpecialPreferences.php @@ -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' ); } diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 39f9d6d64a..88f2061a30 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 7c6f5a059b..0172777e62 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -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', -- 2.20.1