diff options
author | raul | 2014-06-24 16:58:54 +0200 |
---|---|---|
committer | Michael Pereira Neves | 2014-07-11 15:01:59 +0200 |
commit | 2ee30c8128a464386f87be428f3ab3061d073e40 (patch) | |
tree | 85af1f5d429668d99dae06fb9cdd3b081829ad84 | |
parent | [i18n] add i18n support, WIP (diff) | |
download | slx-admin-2ee30c8128a464386f87be428f3ab3061d073e40.tar.gz slx-admin-2ee30c8128a464386f87be428f3ab3061d073e40.tar.xz slx-admin-2ee30c8128a464386f87be428f3ab3061d073e40.zip |
[i18n] implemented translator logic
-rw-r--r-- | dictionary.json | 161 | ||||
-rw-r--r-- | dictionary.php | 16 | ||||
-rw-r--r-- | inc/render.inc.php | 3 | ||||
-rw-r--r-- | index.php | 9 |
4 files changed, 150 insertions, 39 deletions
diff --git a/dictionary.json b/dictionary.json index 251de4ea..fec402da 100644 --- a/dictionary.json +++ b/dictionary.json @@ -1,31 +1,132 @@ -{ "activeNews":{ - "english":"Active News", - "german":"Aktive News", - "portuguese":"Novidades" - }, -"content":{ - "english":"Content", - "german":"Inhalt", - "portuguese":"Conteúdo" - }, -"latestUpdate":{ - "english":"Latest update", - "german":"Letzte Aktualisierung", - "portuguese":"Última atualização" - }, -"save":{ - "english":"Save", - "german":"Speichern", - "portuguese":"Salvar" - }, -"title":{ - "english":"Title", - "german":"Titel", - "portuguese":"Título" - }, -"welcome":{ - "english":"Welcome", - "german":"Willkommen", - "portuguese":"Bem-vindo" - } +{ + "activeNews": { + "english": "Active News", + "german": "Aktive News", + "portuguese": "Novidades" + }, + "confirmation": { + "english": "Confirmation", + "german": "Wiederholen", + "portuguese": "Confirmação" + }, + "content": { + "english": "Content", + "german": "Inhalt", + "portuguese": "Conteúdo" + }, + "close": { + "english": "Close", + "german": "Schließen", + "portuguese": "Fechar" + }, + "configurationBasic": { + "english": "Basic Configuration", + "german": "Grundkonfiguration", + "portuguese": "Configuração Básica" + }, + "configurationVariables": { + "english": "Configuration Variables", + "german": "KonfigurationsVariablen", + "portuguese": "Variáveis de Configuração" + }, + "createUser": { + "english": "Create User", + "german": "Benutzer anlegen", + "portuguese": "Criar Usuário" + }, + "enter": { + "english": "Enter", + "german": "Anmeldung", + "portuguese": "Entrar" + }, + "fullName": { + "english": "Full Name", + "german": "Vollständiger Name", + "portuguese": "Nome Completo" + }, + "latestUpdate": { + "english": "Latest update", + "german": "Letzte Aktualisierung", + "portuguese": "Última atualização" + }, + "localization": { + "english": "Localization", + "german": "Lokalisierung", + "portuguese": "Localização" + }, + "login": { + "english": "Login", + "german": "Anmelden", + "portuguese": "Entrar" + }, + "logout": { + "english": "Logout", + "german": "Abmelden", + "portuguese": "Sair" + }, + "news": { + "english": "News", + "german": "News", + "portuguese": "Novidades" + }, + "nextD": { + "english": "Next", + "german": "Weiter", + "portuguese": "Próximo" + }, + "password": { + "english": "Password", + "german": "Passwort", + "portuguese": "Senha" + }, + "register": { + "english": "Register", + "german": "Registrieren", + "portuguese": "Registrar" + }, + "rememberID": { + "english": "Remeber ID", + "german": "Angemeldet bleiben", + "portuguese": "Lembrar ID" + }, + "reset": { + "english": "Reset", + "german": "Zurücksetzen", + "portuguese": "Limpar" + }, + "save": { + "english": "Save", + "german": "Speichern", + "portuguese": "Salvar" + }, + "settings": { + "english": "Settings", + "german": "Einstellungen", + "portuguese": "Opções" + }, + "telephone": { + "english": "Telephone", + "german": "Telefon", + "portuguese": "Telefone" + }, + "title": { + "english": "Title", + "german": "Titel", + "portuguese": "Título" + }, + "username": { + "english": "Username", + "german": "Benutzerkennung", + "portuguese": "Nome de Usuário" + }, + "vmLocation": { + "english": "VM Location", + "german": "VM Speicherort", + "portuguese": "Localização da VM" + }, + "welcome": { + "english": "Welcome", + "german": "Willkommen", + "portuguese": "Bem-vindo" + } } diff --git a/dictionary.php b/dictionary.php index 9563f7c3..00834a49 100644 --- a/dictionary.php +++ b/dictionary.php @@ -1,14 +1,18 @@ <?php class Dictionary{ - private $dictionary; + private static $dictionary; + private static $langArray; - function __construct(){ - $this->dictionary = json_decode(file_get_contents("dictionary.json"),true); + function build(){ + self::$dictionary = json_decode(file_get_contents("dictionary.json"),true); + foreach(self::$dictionary as $key => $text){ + self::$langArray[$key] = $text[LANG]; + } } - - public function translate($text){ - return $this->dictionary[$text][LANG]; + public static function getArray(){ + return self::$langArray; } + } diff --git a/inc/render.inc.php b/inc/render.inc.php index 5eabdaca..3d5b3864 100644 --- a/inc/render.inc.php +++ b/inc/render.inc.php @@ -163,9 +163,10 @@ class Render */ public static function parse($template, $params = false) { + $dictionary = Dictionary::getArray(); if (is_array($params) || $params === false || is_null($params)) $params['token'] = Session::get('token'); - return self::$mustache->render(self::getTemplate($template), $params); + return self::$mustache->render(self::getTemplate($template), array_merge($dictionary,$params)); } /** @@ -3,7 +3,9 @@ require_once 'config.php'; require_once 'dictionary.php'; +Dictionary::build(); +require_once('inc/user.inc.php'); /** * Page class which all "modules" must be extending from @@ -115,8 +117,11 @@ if (AJAX) { Page::preprocess(); // Generate Main menu -$menu = new Menu; -Render::addTemplate('main-menu', $menu); +//$menu = new Menu; +if(User::getName() === false) Render::addTemplate('main-menu-login'); +else Render::addTemplate('main-menu-logout',array( + 'user' => User::getName() + )); Message::renderList(); |