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
This commit is contained in:
ryan 2009-05-14 18:58:37 +00:00
parent 60b524160c
commit 4cda93b364
1 changed files with 27 additions and 8 deletions

View File

@ -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<option ".((($continent.'/'.$city)==$selectedzone)?'selected="selected"':'')." value=\"".($continent.'/'.$city)."\">$pad".$display."</option>\n"; //Timezone