aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2014-09-17 15:54:00 +0200
committerMarc Alexander <admin@m-a-styles.de>2014-09-17 17:56:04 +0200
commit9a3aeb8a99e7edeb38b5791adf71cfd13059957b (patch)
tree3e7c4c0225fa25f8d5a1d0b8f30f1431b4238725
parent3dbac0f88ba056b19b29fdcabd76074a8dd250d5 (diff)
downloadforums-9a3aeb8a99e7edeb38b5791adf71cfd13059957b.tar
forums-9a3aeb8a99e7edeb38b5791adf71cfd13059957b.tar.gz
forums-9a3aeb8a99e7edeb38b5791adf71cfd13059957b.tar.bz2
forums-9a3aeb8a99e7edeb38b5791adf71cfd13059957b.tar.xz
forums-9a3aeb8a99e7edeb38b5791adf71cfd13059957b.zip
[ticket/12858] Remove hardcoded language entries from timezone selects
PHPBB3-12858
-rw-r--r--phpBB/assets/javascript/core.js6
-rw-r--r--phpBB/includes/functions.php30
-rw-r--r--phpBB/language/en/common.php54
-rw-r--r--phpBB/styles/prosilver/template/timezone_option.html2
4 files changed, 48 insertions, 44 deletions
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index b5187991f9..6ddbba7515 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -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;
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index d5a7bd925b..0678ea7fda 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -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,
));
}
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index 83e1f4eaa1..79d504a67d 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -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',
-
- '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',
+ 'UTC' => 'UTC',
+ 'UTC_OFFSET' => 'UTC%1$s',
+ 'UTC_OFFSET_CURRENT' => 'UTC%1$s - %2$s',
+
+ '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',
diff --git a/phpBB/styles/prosilver/template/timezone_option.html b/phpBB/styles/prosilver/template/timezone_option.html
index 291283c7ca..8f9017b2ef 100644
--- a/phpBB/styles/prosilver/template/timezone_option.html
+++ b/phpBB/styles/prosilver/template/timezone_option.html
@@ -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 -->