mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-21 08:12:17 +02:00
[ticket/12858] Remove hardcoded language entries from timezone selects
PHPBB3-12858
This commit is contained in:
parent
3dbac0f88b
commit
9a3aeb8a99
@ -786,7 +786,7 @@ phpbb.timezoneSwitchDate = function(keepSelection) {
|
||||
}
|
||||
|
||||
if ($tzDate.val() !== '') {
|
||||
$timezone.children('optgroup').remove(':not([label="' + $('#tz_date').val() + '"])');
|
||||
$timezone.children('optgroup').remove(':not([data-tz-value="' + $('#tz_date').val() + '"])');
|
||||
}
|
||||
|
||||
if ($tzDate.val() === $tzSelectDateSuggest.attr('data-suggested-tz')) {
|
||||
@ -795,7 +795,7 @@ phpbb.timezoneSwitchDate = function(keepSelection) {
|
||||
$tzSelectDateSuggest.css('display', 'inline');
|
||||
}
|
||||
|
||||
var $tzOptions = $timezone.children('optgroup[label="' + $tzDate.val() + '"]').children('option');
|
||||
var $tzOptions = $timezone.children('optgroup[data-tz-value="' + $tzDate.val() + '"]').children('option');
|
||||
|
||||
if ($tzOptions.length === 1) {
|
||||
// If there is only one timezone for the selected date, we just select that automatically.
|
||||
@ -849,7 +849,7 @@ phpbb.timezonePreselectSelect = function(forceSelector) {
|
||||
minutes = minutes.toString();
|
||||
}
|
||||
|
||||
var prefix = 'GMT' + sign + hours + ':' + minutes;
|
||||
var prefix = 'UTC' + sign + hours + ':' + minutes;
|
||||
var prefixLength = prefix.length;
|
||||
var selectorOptions = $('option', '#tz_date');
|
||||
var i;
|
||||
|
@ -937,15 +937,16 @@ function style_select($default = '', $all = false)
|
||||
* Format the timezone offset with hours and minutes
|
||||
*
|
||||
* @param int $tz_offset Timezone offset in seconds
|
||||
* @param bool $show_null Whether null offsets should be shown
|
||||
* @return string Normalized offset string: -7200 => -02:00
|
||||
* 16200 => +04:30
|
||||
*/
|
||||
function phpbb_format_timezone_offset($tz_offset)
|
||||
function phpbb_format_timezone_offset($tz_offset, $show_null = false)
|
||||
{
|
||||
$sign = ($tz_offset < 0) ? '-' : '+';
|
||||
$time_offset = abs($tz_offset);
|
||||
|
||||
if ($time_offset == 0)
|
||||
if ($time_offset == 0 && $show_null == false)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
@ -1068,15 +1069,15 @@ function phpbb_timezone_select($template, $user, $default = '', $truncate = fals
|
||||
$dt = $user->create_datetime('now', $tz);
|
||||
$offset = $dt->getOffset();
|
||||
$current_time = $dt->format($user->lang['DATETIME_FORMAT'], true);
|
||||
$offset_string = phpbb_format_timezone_offset($offset);
|
||||
$timezones['GMT' . $offset_string . ' - ' . $timezone] = array(
|
||||
$offset_string = phpbb_format_timezone_offset($offset, true);
|
||||
$timezones['UTC' . $offset_string . ' - ' . $timezone] = array(
|
||||
'tz' => $timezone,
|
||||
'offset' => 'GMT' . $offset_string,
|
||||
'offset' => $offset_string,
|
||||
'current' => $current_time,
|
||||
);
|
||||
if ($timezone === $default)
|
||||
{
|
||||
$default_offset = 'GMT' . $offset_string;
|
||||
$default_offset = 'UTC' . $offset_string;
|
||||
}
|
||||
}
|
||||
unset($unsorted_timezones);
|
||||
@ -1086,23 +1087,24 @@ function phpbb_timezone_select($template, $user, $default = '', $truncate = fals
|
||||
|
||||
$tz_select = $opt_group = '';
|
||||
|
||||
foreach ($timezones as $timezone)
|
||||
foreach ($timezones as $key => $timezone)
|
||||
{
|
||||
if ($opt_group != $timezone['offset'])
|
||||
{
|
||||
// Generate tz_select for backwards compatibility
|
||||
$tz_select .= ($opt_group) ? '</optgroup>' : '';
|
||||
$tz_select .= '<optgroup label="' . $timezone['offset'] . ' - ' . $timezone['current'] . '">';
|
||||
$tz_select .= '<optgroup label="' . $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']) . '">';
|
||||
$opt_group = $timezone['offset'];
|
||||
$template->assign_block_vars('tz_select', array(
|
||||
'LABEL' => $timezone['offset'] . ' - ' . $timezone['current'],
|
||||
'LABEL' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']),
|
||||
'VALUE' => $key . ' - ' . $timezone['current'],
|
||||
));
|
||||
|
||||
$selected = ($default_offset == $timezone['offset']) ? ' selected="selected"' : '';
|
||||
$selected = (!empty($default_offset) && strpos($key, $default_offset) !== false) ? ' selected="selected"' : '';
|
||||
$template->assign_block_vars('tz_date', array(
|
||||
'VALUE' => $timezone['offset'] . ' - ' . $timezone['current'],
|
||||
'SELECTED' => $selected,
|
||||
'TITLE' => $timezone['offset'] . ' - ' . $timezone['current'],
|
||||
'VALUE' => $key . ' - ' . $timezone['current'],
|
||||
'SELECTED' => !empty($selected),
|
||||
'TITLE' => $user->lang(array('timezones', 'UTC_OFFSET_CURRENT'), $timezone['offset'], $timezone['current']),
|
||||
));
|
||||
}
|
||||
|
||||
@ -1124,7 +1126,7 @@ function phpbb_timezone_select($template, $user, $default = '', $truncate = fals
|
||||
$template->assign_block_vars('tz_select.tz_options', array(
|
||||
'TITLE' => $title,
|
||||
'VALUE' => $timezone['tz'],
|
||||
'SELECTED' => $timezone['tz'] === $default,
|
||||
'SELECTED' => !empty($selected),
|
||||
'LABEL' => $label,
|
||||
));
|
||||
}
|
||||
|
@ -937,32 +937,34 @@ $lang = array_merge($lang, array(
|
||||
// Timezones can be translated. We use this for the Etc/GMT timezones here,
|
||||
// because they are named invers to their offset.
|
||||
'timezones' => array(
|
||||
'UTC' => 'UTC',
|
||||
'UTC' => 'UTC',
|
||||
'UTC_OFFSET' => 'UTC%1$s',
|
||||
'UTC_OFFSET_CURRENT' => 'UTC%1$s - %2$s',
|
||||
|
||||
'Etc/GMT-12' => 'GMT+12',
|
||||
'Etc/GMT-11' => 'GMT+11',
|
||||
'Etc/GMT-10' => 'GMT+10',
|
||||
'Etc/GMT-9' => 'GMT+9',
|
||||
'Etc/GMT-8' => 'GMT+8',
|
||||
'Etc/GMT-7' => 'GMT+7',
|
||||
'Etc/GMT-6' => 'GMT+6',
|
||||
'Etc/GMT-5' => 'GMT+5',
|
||||
'Etc/GMT-4' => 'GMT+4',
|
||||
'Etc/GMT-3' => 'GMT+3',
|
||||
'Etc/GMT-2' => 'GMT+2',
|
||||
'Etc/GMT-1' => 'GMT+1',
|
||||
'Etc/GMT+1' => 'GMT-1',
|
||||
'Etc/GMT+2' => 'GMT-2',
|
||||
'Etc/GMT+3' => 'GMT-3',
|
||||
'Etc/GMT+4' => 'GMT-4',
|
||||
'Etc/GMT+5' => 'GMT-5',
|
||||
'Etc/GMT+6' => 'GMT-6',
|
||||
'Etc/GMT+7' => 'GMT-7',
|
||||
'Etc/GMT+8' => 'GMT-8',
|
||||
'Etc/GMT+9' => 'GMT-9',
|
||||
'Etc/GMT+10' => 'GMT-10',
|
||||
'Etc/GMT+11' => 'GMT-11',
|
||||
'Etc/GMT+12' => 'GMT-12',
|
||||
'Etc/GMT-12' => 'UTC+12',
|
||||
'Etc/GMT-11' => 'UTC+11',
|
||||
'Etc/GMT-10' => 'UTC+10',
|
||||
'Etc/GMT-9' => 'UTC+9',
|
||||
'Etc/GMT-8' => 'UTC+8',
|
||||
'Etc/GMT-7' => 'UTC+7',
|
||||
'Etc/GMT-6' => 'UTC+6',
|
||||
'Etc/GMT-5' => 'UTC+5',
|
||||
'Etc/GMT-4' => 'UTC+4',
|
||||
'Etc/GMT-3' => 'UTC+3',
|
||||
'Etc/GMT-2' => 'UTC+2',
|
||||
'Etc/GMT-1' => 'UTC+1',
|
||||
'Etc/GMT+1' => 'UTC-1',
|
||||
'Etc/GMT+2' => 'UTC-2',
|
||||
'Etc/GMT+3' => 'UTC-3',
|
||||
'Etc/GMT+4' => 'UTC-4',
|
||||
'Etc/GMT+5' => 'UTC-5',
|
||||
'Etc/GMT+6' => 'UTC-6',
|
||||
'Etc/GMT+7' => 'UTC-7',
|
||||
'Etc/GMT+8' => 'UTC-8',
|
||||
'Etc/GMT+9' => 'UTC-9',
|
||||
'Etc/GMT+10' => 'UTC-10',
|
||||
'Etc/GMT+11' => 'UTC-11',
|
||||
'Etc/GMT+12' => 'UTC-12',
|
||||
|
||||
'Africa/Abidjan' => 'Africa/Abidjan',
|
||||
'Africa/Accra' => 'Africa/Accra',
|
||||
|
@ -15,7 +15,7 @@
|
||||
<select name="tz" id="timezone" class="autowidth tz_select">
|
||||
<option value="">{L_SELECT_TIMEZONE}</option>
|
||||
<!-- BEGIN tz_select -->
|
||||
<optgroup label="{tz_select.LABEL}">
|
||||
<optgroup label="{tz_select.LABEL}" data-tz-value="{tz_select.VALUE}">
|
||||
<!-- BEGIN tz_options -->
|
||||
<option title="{tz_select.tz_options.TITLE}" value="{tz_select.tz_options.VALUE}"<!-- IF tz_select.tz_options.SELECTED --> selected="selected"<!-- ENDIF -->>{tz_select.tz_options.LABEL}</option>
|
||||
<!-- END tz_options -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user