issue #39: changing language files to represent their respective

locales, change date format to use strftime(%x %X), making %e usage
windows compatible, and fixing yesterday_format and other_format,
updating language filename in README
This commit is contained in:
Pepijn Over 2014-03-27 22:31:39 +01:00
parent 3e68040fb5
commit f6926334ce
12 changed files with 74 additions and 86 deletions

View File

@ -12,7 +12,7 @@
- Added user profile page. - Added user profile page.
- Added history tracking of server uptime. - Added history tracking of server uptime.
- Added history graphs of server uptime and latency (thanks to Jérôme Cabanis). - Added history graphs of server uptime and latency (thanks to Jérôme Cabanis).
- Date format is taken from language file and localized per language (thanks to Jérôme Cabanis). - Date and time formats are taken from language file and localized per language (thanks to Jérôme Cabanis).
- When checking a website, the updater will now follow 302 Location headers. - When checking a website, the updater will now follow 302 Location headers.
- String/pattern search on websites did not work for websites with compression turned on. - String/pattern search on websites did not work for websites with compression turned on.
- Switched from mysql_* to PDO. - Switched from mysql_* to PDO.

View File

@ -134,7 +134,7 @@ If you would like to contribute a patch or feature, please fork the develop bran
### Changing the email or text message ### Changing the email or text message
Go to the folder "src/lang", open the language file that corresponds to the selected language Go to the folder "src/lang", open the language file that corresponds to the selected language
(default is English ("en.lang.php")). Scroll all the way to the bottom until you spot this line: (default is English ("en_US.lang.php")). Scroll all the way to the bottom until you spot this line:
'notifications' => array( 'notifications' => array(

View File

@ -93,5 +93,5 @@ if($db->status() && (!defined('PSM_INSTALL') || !PSM_INSTALL)) {
die(); die();
} }
} }
$lang = psm_get_conf('language', 'en'); $lang = psm_get_conf('language', 'en_US');
psm_load_lang($lang); psm_load_lang($lang);

View File

@ -63,8 +63,8 @@ function psm_load_lang($lang) {
$lang_file = PSM_PATH_LANG . $lang . '.lang.php'; $lang_file = PSM_PATH_LANG . $lang . '.lang.php';
if(!file_exists($lang_file)) { if(!file_exists($lang_file)) {
// If the file have been removed, we use the english one // If the file has been removed, we use the english one
$en_file = PSM_PATH_LANG . 'en.lang.php'; $en_file = PSM_PATH_LANG . 'en_US.lang.php';
if(!file_exists($en_file)) { if(!file_exists($en_file)) {
// OK, nothing we can do // OK, nothing we can do
die('unable to load language file: ' . $lang_file); die('unable to load language file: ' . $lang_file);
@ -73,10 +73,8 @@ function psm_load_lang($lang) {
} }
require $lang_file; require $lang_file;
if(isset($sm_lang['locale'])) $locale = basename($lang_file, '.lang.php');
{ setlocale(LC_TIME, $locale);
setlocale(LC_TIME, $sm_lang['locale']);
}
$GLOBALS['sm_lang'] = $sm_lang; $GLOBALS['sm_lang'] = $sm_lang;
} }
@ -98,17 +96,15 @@ function psm_get_langs() {
if(file_exists($file)) { if(file_exists($file)) {
require $file; require $file;
} }
if(isset($sm_lang['name'])) if(isset($sm_lang['name'])) {
{
$name = $sm_lang['name']; $name = $sm_lang['name'];
} } else {
else
{
$name = $key; $name = $key;
} }
$langs[$key] = $name; $langs[$key] = $name;
unset($sm_lang); unset($sm_lang);
} }
ksort($langs);
return $langs; return $langs;
} }
@ -274,14 +270,19 @@ function psm_curl_get($href, $header = false, $body = true, $timeout = 10, $add_
* Source: http://www.interactivetools.com/forum/forum-posts.php?postNum=2208966 * Source: http://www.interactivetools.com/forum/forum-posts.php?postNum=2208966
* @param string $time * @param string $time
* @return string * @return string
* @todo add translation to timespan messages
*/ */
function psm_timespan($time) { function psm_timespan($time) {
if(empty($time) || $time == '0000-00-00 00:00:00') if(empty($time) || $time == '0000-00-00 00:00:00') {
return psm_get_lang(system, 'never'); return psm_get_lang('system', 'never');
}
if ($time !== intval($time)) { $time = strtotime($time); } if ($time !== intval($time)) { $time = strtotime($time); }
if ($time < strtotime(date('Y-m-d 00:00:00')) - 60*60*24*3) { if ($time < strtotime(date('Y-m-d 00:00:00')) - 60*60*24*3) {
$format = psm_get_lang('system', (date('Y') !== date('Y', $time)) ? 'long_day_format' : 'short_day_format'); $format = psm_get_lang('system', (date('Y') !== date('Y', $time)) ? 'long_day_format' : 'short_day_format');
// Check for Windows to find and replace the %e
// modifier correctly
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$format = preg_replace('#(?<!%)((?:%%)*)%e#', '\1%#d', $format);
}
return strftime($format, $time); return strftime($format, $time);
} }
$d = time() - $time; $d = time() - $time;
@ -302,13 +303,12 @@ function psm_timespan($time) {
* Get a localised date from MySQL date format * Get a localised date from MySQL date format
* @param string $time * @param string $time
* @return string * @return string
* @todo add translation
*/ */
function psm_date($time) function psm_date($time) {
{ if(empty($time) || $time == '0000-00-00 00:00:00') {
if(empty($time) || $time == '0000-00-00 00:00:00') return psm_get_lang('system', 'never');
return psm_get_lang(system, 'never'); }
return date(psm_get_lang('system', 'date_time_format'), strtotime($time)); return strftime('%x %X', strtotime($time));
} }
/** /**

View File

@ -26,8 +26,7 @@
**/ **/
$sm_lang = array( $sm_lang = array(
'name' => 'Български', 'name' => 'Български - Bulgarian',
'locale' => 'bg_BG', // Language code (ISO 639-1) + Contry code (ISO_3166-1)
'system' => array( 'system' => array(
'title' => 'Server Monitor', 'title' => 'Server Monitor',
'install' => 'Инсталация', 'install' => 'Инсталация',
@ -46,13 +45,11 @@ $sm_lang = array(
'update_available' => 'Налична е нова версия. Може да я свалите от <a href="http://www.phpservermonitor.org" target="_blank">тук</a>.', 'update_available' => 'Налична е нова версия. Може да я свалите от <a href="http://www.phpservermonitor.org" target="_blank">тук</a>.',
'back_to_top' => 'Нагоре', 'back_to_top' => 'Нагоре',
'go_back' => 'Go back', 'go_back' => 'Go back',
// date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'date_time_format' => 'd.m.Y H:i:s', // date/time format according the date php function format parameter http://php.net/manual/function.date.php 'short_day_format' => '%B %e',
'short_day_format' => '%B %e', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'long_day_format' => '%B %e, %Y', 'long_day_format' => '%B %e, %Y',
'yesterday_format' => 'Yesterday at %l:%Ma', 'yesterday_format' => 'Yesterday at %k:%M',
'other_day_format' => '%A at g:ia', 'other_day_format' => '%A at %k:%M',
'never' => 'Never', 'never' => 'Never',
'hours_ago' => '%d hours ago', 'hours_ago' => '%d hours ago',
'an_hour_ago' => 'about an hour ago', 'an_hour_ago' => 'about an hour ago',

View File

@ -26,8 +26,7 @@
**/ **/
$sm_lang = array( $sm_lang = array(
'name' => 'Dutch', 'name' => 'Deutsch - German',
'locale' => 'de_DE', // Language code (ISO 639-1) + Contry code (ISO_3166-1)
'system' => array( 'system' => array(
'title' => 'Server Monitor', 'title' => 'Server Monitor',
'install' => 'Install', 'install' => 'Install',
@ -46,13 +45,11 @@ $sm_lang = array(
'update_available' => 'Ein neues Update ist verf&uuml;gbar auf <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.', 'update_available' => 'Ein neues Update ist verf&uuml;gbar auf <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.',
'back_to_top' => 'Back to top', 'back_to_top' => 'Back to top',
'go_back' => 'Go back', 'go_back' => 'Go back',
// date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'date_time_format' => 'd.m.Y H:i:s', // date/time format according the date php function format parameter http://php.net/manual/function.date.php 'short_day_format' => '%B %e',
'short_day_format' => '%B %e', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'long_day_format' => '%B %e, %Y', 'long_day_format' => '%B %e, %Y',
'yesterday_format' => 'Yesterday at %l:%Ma', 'yesterday_format' => 'Gestern um %k:%M',
'other_day_format' => '%A at g:ia', 'other_day_format' => '%A um %k:%M',
'never' => 'Never', 'never' => 'Never',
'hours_ago' => '%d hours ago', 'hours_ago' => '%d hours ago',
'an_hour_ago' => 'about an hour ago', 'an_hour_ago' => 'about an hour ago',

View File

@ -27,7 +27,6 @@
$sm_lang = array( $sm_lang = array(
'name' => 'English', 'name' => 'English',
'locale' => 'en_US', // Language code (ISO 639-1) + Contry code (ISO_3166-1)
'system' => array( 'system' => array(
'title' => 'Server Monitor', 'title' => 'Server Monitor',
'install' => 'Install', 'install' => 'Install',
@ -46,13 +45,11 @@ $sm_lang = array(
'update_available' => 'A new update is available from <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.', 'update_available' => 'A new update is available from <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.',
'back_to_top' => 'Back to top', 'back_to_top' => 'Back to top',
'go_back' => 'Go back', 'go_back' => 'Go back',
// date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'date_time_format' => 'Y-m-d g:i:sa', // date/time format according the date php function format parameter http://php.net/manual/function.date.php 'short_day_format' => '%B %e',
'short_day_format' => '%B %e', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'long_day_format' => '%B %e, %Y', 'long_day_format' => '%B %e, %Y',
'yesterday_format' => 'Yesterday at %l:%Ma', 'yesterday_format' => 'Yesterday at %k:%M',
'other_day_format' => '%A at g:ia', 'other_day_format' => '%A at %k:%M',
'never' => 'Never', 'never' => 'Never',
'hours_ago' => '%d hours ago', 'hours_ago' => '%d hours ago',
'an_hour_ago' => 'about an hour ago', 'an_hour_ago' => 'about an hour ago',

View File

@ -26,8 +26,7 @@
**/ **/
$sm_lang = array( $sm_lang = array(
'name' => 'Français', 'name' => 'Français - French',
'locale' => 'fr_FR', // Language code (ISO 639-1) + Contry code (ISO_3166-1)
'system' => array( 'system' => array(
'title' => 'Server Monitor', 'title' => 'Server Monitor',
'install' => 'Installer', 'install' => 'Installer',
@ -46,10 +45,8 @@ $sm_lang = array(
'update_available' => 'Une nouvelle version est disponible à l\'adresse <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.', 'update_available' => 'Une nouvelle version est disponible à l\'adresse <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.',
'back_to_top' => 'Haut de page', 'back_to_top' => 'Haut de page',
'go_back' => 'Retour', 'go_back' => 'Retour',
// date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'date_time_format' => 'd/m/Y H:i:s', // date/time format according the date php function format parameter http://php.net/manual/function.date.php 'short_day_format' => 'Le %e %B',
'short_day_format' => 'Le %e %B', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'long_day_format' => 'Le %e %B %Y', 'long_day_format' => 'Le %e %B %Y',
'yesterday_format' => 'Hier à %kh%M', 'yesterday_format' => 'Hier à %kh%M',
'other_day_format' => '%A à %kh%M', 'other_day_format' => '%A à %kh%M',

View File

@ -26,8 +26,7 @@
**/ **/
$sm_lang = array( $sm_lang = array(
'name' => '한국', 'name' => '한국 - Korean',
'locale' => 'ko_KR', // Language code (ISO 639-1) + Contry code (ISO_3166-1)
'system' => array( 'system' => array(
'title' => 'Server Monitor', 'title' => 'Server Monitor',
'install' => 'Install', 'install' => 'Install',
@ -46,13 +45,11 @@ $sm_lang = array(
'update_available' => '새로운 업데이트가 있습니다. 다음사이트를 방문 해 주십시오. <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.', 'update_available' => '새로운 업데이트가 있습니다. 다음사이트를 방문 해 주십시오. <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.',
'back_to_top' => 'Back to top', 'back_to_top' => 'Back to top',
'go_back' => 'Go back', 'go_back' => 'Go back',
// date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'date_time_format' => 'Y-m-d H:i:s', // date/time format according the date php function format parameter http://php.net/manual/function.date.php 'short_day_format' => '%B %e',
'short_day_format' => '%B %e', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'long_day_format' => '%B %e, %Y', 'long_day_format' => '%B %e, %Y',
'yesterday_format' => 'Yesterday at %l:%Ma', 'yesterday_format' => 'Yesterday at %X',
'other_day_format' => '%A at g:ia', 'other_day_format' => '%A at %X',
'never' => 'Never', 'never' => 'Never',
'hours_ago' => '%d hours ago', 'hours_ago' => '%d hours ago',
'an_hour_ago' => 'about an hour ago', 'an_hour_ago' => 'about an hour ago',

View File

@ -26,8 +26,7 @@
**/ **/
$sm_lang = array( $sm_lang = array(
'name' => 'Nederlands', 'name' => 'Nederlands - Dutch',
'locale' => 'nl_NL', // Language code (ISO 639-1) + Contry code (ISO_3166-1)
'system' => array( 'system' => array(
'title' => 'Server Monitor', 'title' => 'Server Monitor',
'install' => 'Install', 'install' => 'Install',
@ -46,25 +45,23 @@ $sm_lang = array(
'update_available' => 'Een nieuwe update is beschikbaar op <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.', 'update_available' => 'Een nieuwe update is beschikbaar op <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.',
'back_to_top' => 'Terug naar boven', 'back_to_top' => 'Terug naar boven',
'go_back' => 'Terug', 'go_back' => 'Terug',
// date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'date_time_format' => 'd-m-Y H:i:s', // date/time format according the date php function format parameter http://php.net/manual/function.date.php 'short_day_format' => '%B %e',
'short_day_format' => '%B %e', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'long_day_format' => '%B %e, %Y', 'long_day_format' => '%B %e, %Y',
'yesterday_format' => 'Yesterday at %l:%Ma', 'yesterday_format' => 'Gisteren om %k:%M',
'other_day_format' => '%A at g:ia', 'other_day_format' => '%A om %k:%M',
'never' => 'Never', 'never' => 'Nooit',
'hours_ago' => '%d hours ago', 'hours_ago' => '%d uren geleden',
'an_hour_ago' => 'about an hour ago', 'an_hour_ago' => 'een uur geleden',
'minutes_ago' => '%d minutes ago', 'minutes_ago' => '%d minuten geleden',
'a_minute_ago' => 'about a minute ago', 'a_minute_ago' => 'een minuut geleden',
'seconds_ago' => '%d seconds ago', 'seconds_ago' => '%d seconden geleden',
'a_second_ago' => 'a second ago', 'a_second_ago' => 'een seconde geleden',
), ),
'menu' => array( 'menu' => array(
'config' => 'Config', 'config' => 'Config',
'server' => 'Servers', 'server' => 'Servers',
'server_history' => 'History', 'server_history' => 'Geschiedenis',
'server_log' => 'Log', 'server_log' => 'Log',
'server_status' => 'Status', 'server_status' => 'Status',
'server_update' => 'Update', 'server_update' => 'Update',
@ -114,7 +111,7 @@ $sm_lang = array(
'type_website' => 'Website', 'type_website' => 'Website',
'type_service' => 'Service', 'type_service' => 'Service',
'pattern' => 'Zoek voor tekst/regex', 'pattern' => 'Zoek voor tekst/regex',
'pattern_description' => 'If this pattern is not found on the website, the server will be marked offline. Regular expressions are allowed.', 'pattern_description' => 'Als dit patroon niet gevonden wordt op de website, zal de server als offline gemarkeerd worden. Regular expressions zijn toegestaan.',
'last_check' => 'Laatst gecontroleerd', 'last_check' => 'Laatst gecontroleerd',
'last_online' => 'Laatst online', 'last_online' => 'Laatst online',
'monitoring' => 'Monitoring', 'monitoring' => 'Monitoring',
@ -128,7 +125,7 @@ $sm_lang = array(
'day' => 'Day', 'day' => 'Day',
'hour' => 'Hour', 'hour' => 'Hour',
'warning_threshold' => 'Warning threshold', 'warning_threshold' => 'Warning threshold',
'warning_threshold_description' => 'Number of failed checks required before it is marked offline.', 'warning_threshold_description' => 'Aantal mislukte pogingen voordat de server als offline gemarkeerd wordt.',
// Charts date format according jqPlot date format http://www.jqplot.com/docs/files/plugins/jqplot-dateAxisRenderer-js.html // Charts date format according jqPlot date format http://www.jqplot.com/docs/files/plugins/jqplot-dateAxisRenderer-js.html
'chart_long_date_format' => '%d-%m-%Y %H:%M:%S', 'chart_long_date_format' => '%d-%m-%Y %H:%M:%S',

View File

@ -26,8 +26,7 @@
**/ **/
$sm_lang = array( $sm_lang = array(
'name' => 'Portugês - Brasil', 'name' => 'Português - Brazilian portuguese',
'locale' => 'pt_BR', // Language code (ISO 639-1) + Contry code (ISO_3166-1)
'system' => array( 'system' => array(
'title' => 'Server Monitor', 'title' => 'Server Monitor',
'install' => 'Install', 'install' => 'Install',
@ -46,13 +45,11 @@ $sm_lang = array(
'update_available' => 'Uma atualização disponível em <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.', 'update_available' => 'Uma atualização disponível em <a href="http://www.phpservermonitor.org" target="_blank">http://www.phpservermonitor.org</a>.',
'back_to_top' => 'Voltar ao topo', 'back_to_top' => 'Voltar ao topo',
'go_back' => 'Go back', 'go_back' => 'Go back',
// date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'date_time_format' => 'd/m/Y H:i:s', // date/time format according the date php function format parameter http://php.net/manual/function.date.php 'short_day_format' => '%B %e',
'short_day_format' => '%B %e', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php
'long_day_format' => '%B %e, %Y', 'long_day_format' => '%B %e, %Y',
'yesterday_format' => 'Yesterday at %l:%Ma', 'yesterday_format' => 'Yesterday at %k:%M',
'other_day_format' => '%A at g:ia', 'other_day_format' => '%A at %k:%M',
'never' => 'Never', 'never' => 'Never',
'hours_ago' => '%d hours ago', 'hours_ago' => '%d hours ago',
'an_hour_ago' => 'about an hour ago', 'an_hour_ago' => 'about an hour ago',

View File

@ -248,6 +248,15 @@ class Installer {
*/ */
protected function upgrade220() { protected function upgrade220() {
$queries = array(); $queries = array();
// language is now stored as language code (ISO 639-1) + country code (ISO 3166-1)
$queries[] = "UPDATE `" . PSM_DB_PREFIX . "config` SET `value`='bg_BG' WHERE `key`='language' AND `value`='bg';";
$queries[] = "UPDATE `" . PSM_DB_PREFIX . "config` SET `value`='de_DE' WHERE `key`='language' AND `value`='de';";
$queries[] = "UPDATE `" . PSM_DB_PREFIX . "config` SET `value`='en_US' WHERE `key`='language' AND `value`='en';";
$queries[] = "UPDATE `" . PSM_DB_PREFIX . "config` SET `value`='fr_FR' WHERE `key`='language' AND `value`='fr';";
$queries[] = "UPDATE `" . PSM_DB_PREFIX . "config` SET `value`='ko_KR' WHERE `key`='language' AND `value`='kr';";
$queries[] = "UPDATE `" . PSM_DB_PREFIX . "config` SET `value`='nl_NL' WHERE `key`='language' AND `value`='nl';";
$queries[] = "UPDATE `" . PSM_DB_PREFIX . "config` SET `value`='pt_BR' WHERE `key`='language' AND `value`='br';";
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "log` CHANGE `log_id` `log_id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "log` CHANGE `log_id` `log_id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT;";
$queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "log` CHANGE `server_id` `server_id` INT( 11 ) UNSIGNED NOT NULL;"; $queries[] = "ALTER TABLE `" . PSM_DB_PREFIX . "log` CHANGE `server_id` `server_id` INT( 11 ) UNSIGNED NOT NULL;";