From 52803e2d707b9efba8683d08d5548e97f100a8ae Mon Sep 17 00:00:00 2001 From: Pepijn Over Date: Sun, 31 Jan 2016 17:48:59 +0100 Subject: [PATCH] adding language subtags to template and support for right-to-left locales --- CHANGELOG.rst | 1 + docs/credits.rst | 4 ++++ docs/developers.rst | 4 ++++ src/lang/bg_BG.lang.php | 2 ++ src/lang/cs_CZ.lang.php | 2 ++ src/lang/da_DK.lang.php | 2 ++ src/lang/de_DE.lang.php | 2 ++ src/lang/en_US.lang.php | 2 ++ src/lang/es_ES.lang.php | 2 ++ src/lang/fa_IR.lang.php | 10 ++++++---- src/lang/fi_FI.lang.php | 2 ++ src/lang/fr_FR.lang.php | 2 ++ src/lang/it_IT.lang.php | 2 ++ src/lang/ko_KR.lang.php | 2 ++ src/lang/nl_NL.lang.php | 2 ++ src/lang/pl_PL.lang.php | 2 ++ src/lang/pt_BR.lang.php | 2 ++ src/lang/ru_RU.lang.php | 2 ++ src/lang/sv_SE.lang.php | 4 +++- src/lang/tr_TR.lang.php | 2 ++ src/lang/zh_CN.lang.php | 2 ++ src/psm/Router.php | 5 ++++- src/templates/default/main/body.tpl.html | 2 +- 23 files changed, 55 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b8afdd71..87d49ee6 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -7,6 +7,7 @@ not yet released * #161: Added Swedish translation. * #210: Added Finnish translation. +* #201: Added Persian translation. * #195: Updated Spanish translation. * #169: Increased server ip char limit to 500. * #164: Added support for FreeVoipDeal SMS gateway . diff --git a/docs/credits.rst b/docs/credits.rst index b4237595..2de91531 100644 --- a/docs/credits.rst +++ b/docs/credits.rst @@ -111,6 +111,10 @@ The following people have contributed to the translation of PHP Server Monitor: * Ik-Jun +* Persian + + * Javad Evazzadeh Kakroudi - https://github.com/evazzadeh + * Polish * Arkadiusz Klenczar - https://github.com/aklenczar diff --git a/docs/developers.rst b/docs/developers.rst index 5a942d77..96796dc8 100644 --- a/docs/developers.rst +++ b/docs/developers.rst @@ -25,6 +25,10 @@ Each language file should contain a 'locale' key which can be used for formattin For more information, see http://www.php.net/manual/en/function.setlocale.php +For display purposes, the language file should also provide the text direction (ltr / rtl) and language subtag. +Unfortunately they do not match 1:1 with the locales used for the server. +Valid language subtags can be found on http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry. + Adding a new language --------------------- diff --git a/src/lang/bg_BG.lang.php b/src/lang/bg_BG.lang.php index e847efb9..fc3d0c29 100644 --- a/src/lang/bg_BG.lang.php +++ b/src/lang/bg_BG.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Български - Bulgarian', 'locale' => array('bg_BG.UTF-8', 'bg_BG', 'bulgarian'), + 'locale_tag' => 'bg', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Мониторинг', 'install' => 'Инсталация', diff --git a/src/lang/cs_CZ.lang.php b/src/lang/cs_CZ.lang.php index 96ff7434..24d3bcde 100644 --- a/src/lang/cs_CZ.lang.php +++ b/src/lang/cs_CZ.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Česky - Czech', 'locale' => array('cs_CZ.UTF-8', 'cs_CZ', 'czech', 'czech'), + 'locale_tag' => 'cs', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Instalace', diff --git a/src/lang/da_DK.lang.php b/src/lang/da_DK.lang.php index 941397f5..ace8999b 100644 --- a/src/lang/da_DK.lang.php +++ b/src/lang/da_DK.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Dansk - Danish', 'locale' => array('da_DK.UTF-8', 'da_DK', 'danish', 'danish-dk'), + 'locale_tag' => 'da', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Installere', diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index dabf5216..240e4d98 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Deutsch - German', 'locale' => array('de_DE.UTF-8', 'de_DE', 'german'), + 'locale_tag' => 'de', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Installation', diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 2c244966..ab050657 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'English', 'locale' => array('en_US.UTF-8', 'en_US', 'american', 'english-us'), + 'locale_tag' => 'en', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Install', diff --git a/src/lang/es_ES.lang.php b/src/lang/es_ES.lang.php index fbd9bba3..fe12feb9 100644 --- a/src/lang/es_ES.lang.php +++ b/src/lang/es_ES.lang.php @@ -30,6 +30,8 @@ $sm_lang = array( 'name' => 'Español - Spanish', 'locale' => array('es_ES.UTF-8', 'es_ES', 'spanish', 'esp'), + 'locale_tag' => 'es', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Instalar', diff --git a/src/lang/fa_IR.lang.php b/src/lang/fa_IR.lang.php index 5ceede2e..858db6a9 100644 --- a/src/lang/fa_IR.lang.php +++ b/src/lang/fa_IR.lang.php @@ -18,16 +18,18 @@ * along with PHP Server Monitor. If not, see . * * @package phpservermon - * @author Pepijn Over - * @copyright Copyright (c) 2008-2014 Pepijn Over + * @author Javad Evazzadeh Kakroudi + * @copyright Copyright (c) 2008-2015 Pepijn Over * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 - * @version Release: v3.1.1 + * @version Release: @package_version@ * @link http://www.phpservermonitor.org/ **/ $sm_lang = array( 'name' => 'فارسی - Persian', - 'locale' => array('fa_IR.UTF-8', 'fa_IR', 'far', 'per', 'fa', 'lang'=>'fa_IR', 'dir'=>'rtl'), + 'locale' => array('fa_IR.UTF-8', 'fa_IR', 'far', 'per', 'fa'), + 'locale_tag' => 'fa', + 'locale_dir' => 'rtl', 'system' => array( 'title' => 'مانیتورینگ سرور', 'install' => 'نصب', diff --git a/src/lang/fi_FI.lang.php b/src/lang/fi_FI.lang.php index d0665d0d..aa3e73c9 100644 --- a/src/lang/fi_FI.lang.php +++ b/src/lang/fi_FI.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Suomi - Finnish', 'locale' => array('fi_FI.UTF-8', 'fi_FI', 'finnish', 'finnish-fi'), + 'locale_tag' => 'fi', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Asenna', diff --git a/src/lang/fr_FR.lang.php b/src/lang/fr_FR.lang.php index 604b2f23..cf67b7a5 100644 --- a/src/lang/fr_FR.lang.php +++ b/src/lang/fr_FR.lang.php @@ -29,6 +29,8 @@ $sm_lang = array( 'name' => 'Français - French', 'locale' => array('fr_FR.UTF-8', 'fr_FR', 'french'), + 'locale_tag' => 'fr', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Installer', diff --git a/src/lang/it_IT.lang.php b/src/lang/it_IT.lang.php index 3e08505a..a926ba61 100644 --- a/src/lang/it_IT.lang.php +++ b/src/lang/it_IT.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Italiano - Italian', 'locale' => array('it_IT.UTF-8', 'it_IT', 'italian', 'ita'), + 'locale_tag' => 'it', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Install', diff --git a/src/lang/ko_KR.lang.php b/src/lang/ko_KR.lang.php index 74a373b2..ec8f5d4a 100644 --- a/src/lang/ko_KR.lang.php +++ b/src/lang/ko_KR.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => '한국 - Korean', 'locale' => array('ko_KR.UTF-8', 'ko_KR', 'korean'), + 'locale_tag' => 'ko', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Install', diff --git a/src/lang/nl_NL.lang.php b/src/lang/nl_NL.lang.php index a9dfde58..8c9bbf09 100644 --- a/src/lang/nl_NL.lang.php +++ b/src/lang/nl_NL.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Nederlands - Dutch', 'locale' => array('nl_NL.UTF-8', 'nl_NL', 'dutch'), + 'locale_tag' => 'nl', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Installeren', diff --git a/src/lang/pl_PL.lang.php b/src/lang/pl_PL.lang.php index 7109b3e2..3d08eae9 100644 --- a/src/lang/pl_PL.lang.php +++ b/src/lang/pl_PL.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Polski - Polish', 'locale' => array('pl_PL.UTF-8', 'pl_PL', 'polski', 'polski'), + 'locale_tag' => 'pl', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Instalacja', diff --git a/src/lang/pt_BR.lang.php b/src/lang/pt_BR.lang.php index 3989ac78..495e7e16 100644 --- a/src/lang/pt_BR.lang.php +++ b/src/lang/pt_BR.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Português - Brazilian Portuguese', 'locale' => array('pt_BR.UTF-8', 'pt_BR', 'portuguese-brazilian'), + 'locale_tag' => 'BR', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Instalar', diff --git a/src/lang/ru_RU.lang.php b/src/lang/ru_RU.lang.php index e2bf256c..1a5f86d7 100644 --- a/src/lang/ru_RU.lang.php +++ b/src/lang/ru_RU.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Russian - Русский', 'locale' => array('ru_RU.UTF-8', 'ru_RU', 'russian', 'russian'), + 'locale_tag' => 'ru', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Сервер Мониторинг', 'install' => 'Установка', diff --git a/src/lang/sv_SE.lang.php b/src/lang/sv_SE.lang.php index de2f3d0a..6b190956 100644 --- a/src/lang/sv_SE.lang.php +++ b/src/lang/sv_SE.lang.php @@ -21,13 +21,15 @@ * @author andlil * @copyright Copyright (c) 2008-2015 Pepijn Over * @license http://www.gnu.org/licenses/gpl.txt GNU GPL v3 - * @version Release: v3.1.1 + * @version Release: @package_version@ * @link http://www.phpservermonitor.org/ **/ $sm_lang = array( 'name' => 'Svenska - Swedish', 'locale' => array('sv_SE.UTF-8', 'sv_SE', 'svenska', 'svenska-SE'), + 'locale_tag' => 'sv', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Installera', diff --git a/src/lang/tr_TR.lang.php b/src/lang/tr_TR.lang.php index c8bee7ce..4df35c13 100644 --- a/src/lang/tr_TR.lang.php +++ b/src/lang/tr_TR.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => 'Türkçe - Turkish', 'locale' => array('tr_TR.UTF-8', 'tr_TR', 'turkish', 'turkish-tr'), + 'locale_tag' => 'tr', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => 'Yükle', diff --git a/src/lang/zh_CN.lang.php b/src/lang/zh_CN.lang.php index 6099046c..5083abb6 100644 --- a/src/lang/zh_CN.lang.php +++ b/src/lang/zh_CN.lang.php @@ -28,6 +28,8 @@ $sm_lang = array( 'name' => '中文 - Chinese', 'locale' => array('zh_CN.UTF-8', 'zh_CN', 'chinese', 'chinese-cn'), + 'locale_tag' => 'zh', + 'locale_dir' => 'ltr', 'system' => array( 'title' => 'Server Monitor', 'install' => '安装', diff --git a/src/psm/Router.php b/src/psm/Router.php index e0983f23..13e76c05 100644 --- a/src/psm/Router.php +++ b/src/psm/Router.php @@ -52,7 +52,6 @@ class Router { public function __construct() { $this->container = $this->buildServiceContainer(); - $this->buildTwigEnvironment(); $mods = $this->container->getParameter('modules'); @@ -79,6 +78,7 @@ class Router { } else { $controller = $mod; } + $this->buildTwigEnvironment(); $controller = $this->getController($mod, $controller); $action = null; @@ -228,6 +228,9 @@ class Router { } ) ); + $twig->addGlobal('direction_current', psm_get_lang('locale_dir')); + $twig->addGlobal('language_current', psm_get_lang('locale_tag')); + return $twig; } } \ No newline at end of file diff --git a/src/templates/default/main/body.tpl.html b/src/templates/default/main/body.tpl.html index 84a40d2d..00402818 100644 --- a/src/templates/default/main/body.tpl.html +++ b/src/templates/default/main/body.tpl.html @@ -1,6 +1,6 @@ {% block header %} - + {{ title }}