diff --git a/CHANGELOG b/CHANGELOG index e0aa2ca5..170a6adb 100755 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,7 +12,7 @@ - Added user profile page. - Added history tracking of server uptime. - 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. - String/pattern search on websites did not work for websites with compression turned on. - Switched from mysql_* to PDO. diff --git a/README.md b/README.md index 72f0852e..cf56a30e 100755 --- a/README.md +++ b/README.md @@ -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 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( diff --git a/src/bootstrap.php b/src/bootstrap.php index c575fb1c..ffa41336 100755 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -93,5 +93,5 @@ if($db->status() && (!defined('PSM_INSTALL') || !PSM_INSTALL)) { die(); } } -$lang = psm_get_conf('language', 'en'); +$lang = psm_get_conf('language', 'en_US'); psm_load_lang($lang); diff --git a/src/includes/functions.inc.php b/src/includes/functions.inc.php index 505247bb..709a64c3 100755 --- a/src/includes/functions.inc.php +++ b/src/includes/functions.inc.php @@ -63,8 +63,8 @@ function psm_load_lang($lang) { $lang_file = PSM_PATH_LANG . $lang . '.lang.php'; if(!file_exists($lang_file)) { - // If the file have been removed, we use the english one - $en_file = PSM_PATH_LANG . 'en.lang.php'; + // If the file has been removed, we use the english one + $en_file = PSM_PATH_LANG . 'en_US.lang.php'; if(!file_exists($en_file)) { // OK, nothing we can do die('unable to load language file: ' . $lang_file); @@ -73,10 +73,8 @@ function psm_load_lang($lang) { } require $lang_file; - if(isset($sm_lang['locale'])) - { - setlocale(LC_TIME, $sm_lang['locale']); - } + $locale = basename($lang_file, '.lang.php'); + setlocale(LC_TIME, $locale); $GLOBALS['sm_lang'] = $sm_lang; } @@ -98,17 +96,15 @@ function psm_get_langs() { if(file_exists($file)) { require $file; } - if(isset($sm_lang['name'])) - { + if(isset($sm_lang['name'])) { $name = $sm_lang['name']; - } - else - { + } else { $name = $key; } $langs[$key] = $name; unset($sm_lang); } + ksort($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 * @param string $time * @return string - * @todo add translation to timespan messages */ function psm_timespan($time) { - if(empty($time) || $time == '0000-00-00 00:00:00') - return psm_get_lang(system, 'never'); + if(empty($time) || $time == '0000-00-00 00:00:00') { + return psm_get_lang('system', 'never'); + } if ($time !== intval($time)) { $time = strtotime($time); } 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'); + // Check for Windows to find and replace the %e + // modifier correctly + if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { + $format = preg_replace('#(? 'Български', - 'locale' => 'bg_BG', // Language code (ISO 639-1) + Contry code (ISO_3166-1) + 'name' => 'Български - Bulgarian', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Инсталация', @@ -46,13 +45,11 @@ $sm_lang = array( 'update_available' => 'Налична е нова версия. Може да я свалите от тук.', 'back_to_top' => 'Нагоре', 'go_back' => 'Go back', - - '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', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + 'short_day_format' => '%B %e', 'long_day_format' => '%B %e, %Y', - 'yesterday_format' => 'Yesterday at %l:%Ma', - 'other_day_format' => '%A at g:ia', + 'yesterday_format' => 'Yesterday at %k:%M', + 'other_day_format' => '%A at %k:%M', 'never' => 'Never', 'hours_ago' => '%d hours ago', 'an_hour_ago' => 'about an hour ago', diff --git a/src/lang/de.lang.php b/src/lang/de_DE.lang.php similarity index 92% rename from src/lang/de.lang.php rename to src/lang/de_DE.lang.php index e451a1f3..0cafb2f6 100755 --- a/src/lang/de.lang.php +++ b/src/lang/de_DE.lang.php @@ -26,8 +26,7 @@ **/ $sm_lang = array( - 'name' => 'Dutch', - 'locale' => 'de_DE', // Language code (ISO 639-1) + Contry code (ISO_3166-1) + 'name' => 'Deutsch - German', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Install', @@ -46,13 +45,11 @@ $sm_lang = array( 'update_available' => 'Ein neues Update ist verfügbar auf http://www.phpservermonitor.org.', 'back_to_top' => 'Back to top', 'go_back' => 'Go back', - - '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', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + 'short_day_format' => '%B %e', 'long_day_format' => '%B %e, %Y', - 'yesterday_format' => 'Yesterday at %l:%Ma', - 'other_day_format' => '%A at g:ia', + 'yesterday_format' => 'Gestern um %k:%M', + 'other_day_format' => '%A um %k:%M', 'never' => 'Never', 'hours_ago' => '%d hours ago', 'an_hour_ago' => 'about an hour ago', diff --git a/src/lang/en.lang.php b/src/lang/en_US.lang.php similarity index 95% rename from src/lang/en.lang.php rename to src/lang/en_US.lang.php index 889dd134..6c591c8e 100755 --- a/src/lang/en.lang.php +++ b/src/lang/en_US.lang.php @@ -27,7 +27,6 @@ $sm_lang = array( 'name' => 'English', - 'locale' => 'en_US', // Language code (ISO 639-1) + Contry code (ISO_3166-1) 'system' => array( 'title' => 'Server Monitor', 'install' => 'Install', @@ -46,13 +45,11 @@ $sm_lang = array( 'update_available' => 'A new update is available from http://www.phpservermonitor.org.', 'back_to_top' => 'Back to top', 'go_back' => 'Go back', - - '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', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + 'short_day_format' => '%B %e', 'long_day_format' => '%B %e, %Y', - 'yesterday_format' => 'Yesterday at %l:%Ma', - 'other_day_format' => '%A at g:ia', + 'yesterday_format' => 'Yesterday at %k:%M', + 'other_day_format' => '%A at %k:%M', 'never' => 'Never', 'hours_ago' => '%d hours ago', 'an_hour_ago' => 'about an hour ago', diff --git a/src/lang/fr.lang.php b/src/lang/fr_FR.lang.php similarity index 94% rename from src/lang/fr.lang.php rename to src/lang/fr_FR.lang.php index 346f435e..6d6a27cb 100755 --- a/src/lang/fr.lang.php +++ b/src/lang/fr_FR.lang.php @@ -26,8 +26,7 @@ **/ $sm_lang = array( - 'name' => 'Français', - 'locale' => 'fr_FR', // Language code (ISO 639-1) + Contry code (ISO_3166-1) + 'name' => 'Français - French', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Installer', @@ -46,10 +45,8 @@ $sm_lang = array( 'update_available' => 'Une nouvelle version est disponible à l\'adresse http://www.phpservermonitor.org.', 'back_to_top' => 'Haut de page', 'go_back' => 'Retour', - - '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', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + 'short_day_format' => 'Le %e %B', 'long_day_format' => 'Le %e %B %Y', 'yesterday_format' => 'Hier à %kh%M', 'other_day_format' => '%A à %kh%M', diff --git a/src/lang/kr.lang.php b/src/lang/ko_KR.lang.php similarity index 92% rename from src/lang/kr.lang.php rename to src/lang/ko_KR.lang.php index 4ed6e44f..08879fa3 100755 --- a/src/lang/kr.lang.php +++ b/src/lang/ko_KR.lang.php @@ -26,8 +26,7 @@ **/ $sm_lang = array( - 'name' => '한국', - 'locale' => 'ko_KR', // Language code (ISO 639-1) + Contry code (ISO_3166-1) + 'name' => '한국 - Korean', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Install', @@ -46,13 +45,11 @@ $sm_lang = array( 'update_available' => '새로운 업데이트가 있습니다. 다음사이트를 방문 해 주십시오. http://www.phpservermonitor.org.', 'back_to_top' => 'Back to top', 'go_back' => 'Go back', - - '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', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + 'short_day_format' => '%B %e', 'long_day_format' => '%B %e, %Y', - 'yesterday_format' => 'Yesterday at %l:%Ma', - 'other_day_format' => '%A at g:ia', + 'yesterday_format' => 'Yesterday at %X', + 'other_day_format' => '%A at %X', 'never' => 'Never', 'hours_ago' => '%d hours ago', 'an_hour_ago' => 'about an hour ago', diff --git a/src/lang/nl.lang.php b/src/lang/nl_NL.lang.php similarity index 89% rename from src/lang/nl.lang.php rename to src/lang/nl_NL.lang.php index 4d44e03f..d9750c21 100755 --- a/src/lang/nl.lang.php +++ b/src/lang/nl_NL.lang.php @@ -26,8 +26,7 @@ **/ $sm_lang = array( - 'name' => 'Nederlands', - 'locale' => 'nl_NL', // Language code (ISO 639-1) + Contry code (ISO_3166-1) + 'name' => 'Nederlands - Dutch', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Install', @@ -46,25 +45,23 @@ $sm_lang = array( 'update_available' => 'Een nieuwe update is beschikbaar op http://www.phpservermonitor.org.', 'back_to_top' => 'Terug naar boven', 'go_back' => 'Terug', - - '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', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + 'short_day_format' => '%B %e', 'long_day_format' => '%B %e, %Y', - 'yesterday_format' => 'Yesterday at %l:%Ma', - 'other_day_format' => '%A at g:ia', - 'never' => 'Never', - 'hours_ago' => '%d hours ago', - 'an_hour_ago' => 'about an hour ago', - 'minutes_ago' => '%d minutes ago', - 'a_minute_ago' => 'about a minute ago', - 'seconds_ago' => '%d seconds ago', - 'a_second_ago' => 'a second ago', + 'yesterday_format' => 'Gisteren om %k:%M', + 'other_day_format' => '%A om %k:%M', + 'never' => 'Nooit', + 'hours_ago' => '%d uren geleden', + 'an_hour_ago' => 'een uur geleden', + 'minutes_ago' => '%d minuten geleden', + 'a_minute_ago' => 'een minuut geleden', + 'seconds_ago' => '%d seconden geleden', + 'a_second_ago' => 'een seconde geleden', ), 'menu' => array( 'config' => 'Config', 'server' => 'Servers', - 'server_history' => 'History', + 'server_history' => 'Geschiedenis', 'server_log' => 'Log', 'server_status' => 'Status', 'server_update' => 'Update', @@ -114,7 +111,7 @@ $sm_lang = array( 'type_website' => 'Website', 'type_service' => 'Service', '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_online' => 'Laatst online', 'monitoring' => 'Monitoring', @@ -128,7 +125,7 @@ $sm_lang = array( 'day' => 'Day', 'hour' => 'Hour', '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 'chart_long_date_format' => '%d-%m-%Y %H:%M:%S', diff --git a/src/lang/br.lang.php b/src/lang/pt_BR.lang.php similarity index 95% rename from src/lang/br.lang.php rename to src/lang/pt_BR.lang.php index d1b00502..04734b97 100755 --- a/src/lang/br.lang.php +++ b/src/lang/pt_BR.lang.php @@ -26,8 +26,7 @@ **/ $sm_lang = array( - 'name' => 'Portugês - Brasil', - 'locale' => 'pt_BR', // Language code (ISO 639-1) + Contry code (ISO_3166-1) + 'name' => 'Português - Brazilian portuguese', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Install', @@ -46,13 +45,11 @@ $sm_lang = array( 'update_available' => 'Uma atualização disponível em http://www.phpservermonitor.org.', 'back_to_top' => 'Voltar ao topo', 'go_back' => 'Go back', - - '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', // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + // date/time format according the strftime php function format parameter http://php.net/manual/function.strftime.php + 'short_day_format' => '%B %e', 'long_day_format' => '%B %e, %Y', - 'yesterday_format' => 'Yesterday at %l:%Ma', - 'other_day_format' => '%A at g:ia', + 'yesterday_format' => 'Yesterday at %k:%M', + 'other_day_format' => '%A at %k:%M', 'never' => 'Never', 'hours_ago' => '%d hours ago', 'an_hour_ago' => 'about an hour ago', diff --git a/src/psm/Util/Install/Installer.class.php b/src/psm/Util/Install/Installer.class.php index 0f6caaa0..19c05504 100755 --- a/src/psm/Util/Install/Installer.class.php +++ b/src/psm/Util/Install/Installer.class.php @@ -248,6 +248,15 @@ class Installer { */ protected function upgrade220() { $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 `server_id` `server_id` INT( 11 ) UNSIGNED NOT NULL;";