adding language subtags to template and support for right-to-left locales

This commit is contained in:
Pepijn Over 2016-01-31 17:48:59 +01:00
parent daf843df07
commit 52803e2d70
23 changed files with 55 additions and 7 deletions

View File

@ -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 <http://www.freevoipdeal.com>.

View File

@ -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

View File

@ -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
---------------------

View File

@ -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' => 'Инсталация',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -18,16 +18,18 @@
* along with PHP Server Monitor. If not, see <http://www.gnu.org/licenses/>.
*
* @package phpservermon
* @author Pepijn Over <pep@neanderthal-technology.com>
* @copyright Copyright (c) 2008-2014 Pepijn Over <pep@neanderthal-technology.com>
* @author Javad Evazzadeh Kakroudi
* @copyright Copyright (c) 2008-2015 Pepijn Over <pep@peplab.net>
* @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' => 'نصب',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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' => 'Установка',

View File

@ -21,13 +21,15 @@
* @author andlil
* @copyright Copyright (c) 2008-2015 Pepijn Over <pep@peplab.net>
* @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',

View File

@ -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',

View File

@ -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' => '安装',

View File

@ -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;
}
}

View File

@ -1,6 +1,6 @@
{% block header %}
<!DOCTYPE html>
<html lang="en">
<html lang="{{ language_current }}" dir="{{ direction_current }}">
<head>
<meta charset="utf-8">
<title>{{ title }}</title>