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:
parent
60b524160c
commit
4cda93b364
|
@ -3106,8 +3106,18 @@ function wp_timezone_supported() {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function wp_timezone_choice($selectedzone) {
|
function wp_timezone_choice($selectedzone) {
|
||||||
|
static $mo_loaded = false;
|
||||||
|
|
||||||
$continents = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific', 'Etc');
|
$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();
|
$all = timezone_identifiers_list();
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
@ -3123,12 +3133,18 @@ function wp_timezone_choice($selectedzone) {
|
||||||
|
|
||||||
usort($zonen, create_function(
|
usort($zonen, create_function(
|
||||||
'$a, $b', '
|
'$a, $b', '
|
||||||
if ( $a["continent"] == $b["continent"] && $a["city"] == $b["city"] )
|
$a_continent = translate($a["continent"]);
|
||||||
return strnatcasecmp($a["subcity"], $b["subcity"]);
|
$b_continent = translate($b["continent"]);
|
||||||
elseif ( $a["continent"] == $b["continent"] )
|
$a_city = translate($a["city"]);
|
||||||
return strnatcasecmp($a["city"], $b["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
|
else
|
||||||
return strnatcasecmp($a["continent"], $b["continent"]);
|
return strnatcasecmp($a_continent, $b_continent);
|
||||||
'));
|
'));
|
||||||
|
|
||||||
$structure = '';
|
$structure = '';
|
||||||
|
@ -3151,11 +3167,14 @@ function wp_timezone_choice($selectedzone) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($city) ) {
|
if ( !empty($city) ) {
|
||||||
if ( !empty($subcity) ) {
|
|
||||||
$city = $city . '/'. $subcity;
|
|
||||||
}
|
|
||||||
$display = str_replace('_',' ',$city);
|
$display = str_replace('_',' ',$city);
|
||||||
$display = translate($display);
|
$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' )
|
if ( $continent == 'Etc' )
|
||||||
$display = strtr($display, '+-', '-+');
|
$display = strtr($display, '+-', '-+');
|
||||||
$structure .= "\t<option ".((($continent.'/'.$city)==$selectedzone)?'selected="selected"':'')." value=\"".($continent.'/'.$city)."\">$pad".$display."</option>\n"; //Timezone
|
$structure .= "\t<option ".((($continent.'/'.$city)==$selectedzone)?'selected="selected"':'')." value=\"".($continent.'/'.$city)."\">$pad".$display."</option>\n"; //Timezone
|
||||||
|
|
Loading…
Reference in New Issue