From 4cda93b36424ad429031232df9e1ac1efe98252a Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 14 May 2009 18:58:37 +0000 Subject: [PATCH] Sort tz continents and cities by translated names. Load translations from separate mo to avoid cluttering default pot. Props Denis-de-Bernardy. see #9794 git-svn-id: http://svn.automattic.com/wordpress/trunk@11332 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 1702bc30d..2316e9606 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -3106,8 +3106,18 @@ function wp_timezone_supported() { * */ function wp_timezone_choice($selectedzone) { + static $mo_loaded = false; + $continents = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific', 'Etc'); + // Load translations for continents and cities + if ( ! $mo_loaded ) { + $locale = get_locale(); + $mofile = WP_LANG_DIR . "/continents-cities-$locale.mo"; + load_textdomain('default', $mofile); + $mo_loaded = true; + } + $all = timezone_identifiers_list(); $i = 0; @@ -3123,12 +3133,18 @@ function wp_timezone_choice($selectedzone) { usort($zonen, create_function( '$a, $b', ' - if ( $a["continent"] == $b["continent"] && $a["city"] == $b["city"] ) - return strnatcasecmp($a["subcity"], $b["subcity"]); - elseif ( $a["continent"] == $b["continent"] ) - return strnatcasecmp($a["city"], $b["city"]); + $a_continent = translate($a["continent"]); + $b_continent = translate($b["continent"]); + $a_city = translate($a["city"]); + $b_city = translate($b["city"]); + $a_subcity = translate($a["subcity"]); + $b_subcity = translate($b["subcity"]); + if ( $a_continent == $b_continent && $a_city == $b_city ) + return strnatcasecmp($a_subcity, $b_subcity); + elseif ( $a_continent == $b_continent ) + return strnatcasecmp($a_city, $b_city); else - return strnatcasecmp($a["continent"], $b["continent"]); + return strnatcasecmp($a_continent, $b_continent); ')); $structure = ''; @@ -3151,11 +3167,14 @@ function wp_timezone_choice($selectedzone) { } if ( !empty($city) ) { - if ( !empty($subcity) ) { - $city = $city . '/'. $subcity; - } $display = str_replace('_',' ',$city); $display = translate($display); + if ( !empty($subcity) ) { + $display_subcity = str_replace('_', ' ', $subcity); + $display_subcity = translate($display_subcity); + $city = $city . '/'. $subcity; + $display = $display . '/' . $display_subcity; + } if ( $continent == 'Etc' ) $display = strtr($display, '+-', '-+'); $structure .= "\t\n"; //Timezone