From 4af90a9a1c8c8007cea547383c0de28c62c4e34e Mon Sep 17 00:00:00 2001 From: raul Date: Fri, 13 Jun 2014 16:36:02 -0300 Subject: [i18n] add i18n support, WIP --- config.php | 2 ++ dictionary.json | 31 +++++++++++++++++++++++++++++++ dictionary.php | 14 ++++++++++++++ index.php | 3 +++ lang.txt | 1 + modules/adduser.inc.php | 2 ++ modules/news.inc.php | 10 ++++++++-- modules/sysconfig.inc.php | 2 +- templates/page-news.html | 15 +++++++-------- 9 files changed, 69 insertions(+), 11 deletions(-) create mode 100644 dictionary.json create mode 100644 dictionary.php create mode 100644 lang.txt diff --git a/config.php b/config.php index 179e1a16..c2e9dff2 100644 --- a/config.php +++ b/config.php @@ -14,6 +14,8 @@ define('CONFIG_SQL_PASS', 'geheim'); define('CONFIG_SQL_FORCE_UTF8', false); //define('CONFIG_SQL_DB', 'openslx'); +define('LANG',str_replace("\n", "", file_get_contents('lang.txt'))); + define('CONFIG_TGZ_LIST_DIR', '/opt/openslx/configs'); define('CONFIG_REMOTE_ML', 'http://mltk.boot.openslx.org/update/new'); diff --git a/dictionary.json b/dictionary.json new file mode 100644 index 00000000..251de4ea --- /dev/null +++ b/dictionary.json @@ -0,0 +1,31 @@ +{ "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" + } +} diff --git a/dictionary.php b/dictionary.php new file mode 100644 index 00000000..9563f7c3 --- /dev/null +++ b/dictionary.php @@ -0,0 +1,14 @@ +dictionary = json_decode(file_get_contents("dictionary.json"),true); + } + + + public function translate($text){ + return $this->dictionary[$text][LANG]; + } +} diff --git a/index.php b/index.php index 4b83baaa..e5782e6a 100644 --- a/index.php +++ b/index.php @@ -2,6 +2,9 @@ require_once 'config.php'; +require_once 'dictionary.php'; + + /** * Page class which all "modules" must be extending from */ diff --git a/lang.txt b/lang.txt new file mode 100644 index 00000000..97ab12f0 --- /dev/null +++ b/lang.txt @@ -0,0 +1 @@ +english diff --git a/modules/adduser.inc.php b/modules/adduser.inc.php index 19fa5425..cf224531 100644 --- a/modules/adduser.inc.php +++ b/modules/adduser.inc.php @@ -47,9 +47,11 @@ class Page_AddUser extends Page if (Database::queryFirst('SELECT userid FROM user LIMIT 1') !== false) { Message::addError('adduser-disabled'); } else { + Render::setTitle('Benutzer anlegen'); Render::addTemplate('page-adduser', $_POST); } + } } diff --git a/modules/news.inc.php b/modules/news.inc.php index 2f169fb5..19955978 100644 --- a/modules/news.inc.php +++ b/modules/news.inc.php @@ -85,13 +85,19 @@ class Page_News extends Page if ($row['newsid'] == $this->newsId) $row['active'] = "active"; $lines[] = $row; } - // render each entry + $dictionary = new Dictionary(); $paginate->render('page-news', array( 'token' => Session::get('token'), 'latestDate' => ($this->newsDate ? date('d.m.Y H:i', $this->newsDate) : '--'), 'latestContent' => $this->newsContent, 'latestTitle' => $this->newsTitle, - 'list' => $lines + 'list' => $lines, + 'activeNews' => $dictionary->translate("activeNews"), + 'title' => $dictionary->translate("title"), + 'content' => $dictionary->translate("content"), + 'save' => $dictionary->translate("save"), + 'latestUpdate' => $dictionary->translate("latestUpdate"), + 'welcome' => $dictionary->translate("welcome") )); } diff --git a/modules/sysconfig.inc.php b/modules/sysconfig.inc.php index 8be001e6..1808784e 100644 --- a/modules/sysconfig.inc.php +++ b/modules/sysconfig.inc.php @@ -48,7 +48,7 @@ class Page_SysConfig extends Page if (!User::hasPermission('superadmin')) { Message::addError('no-permission'); - Util::redirect('?do=Main'); + return; } $action = Request::any('action', 'list'); diff --git a/templates/page-news.html b/templates/page-news.html index c9a2ccb3..130ecf3d 100644 --- a/templates/page-news.html +++ b/templates/page-news.html @@ -2,21 +2,20 @@

Hier haben Sie die Möglichkeit, die von bwLehrpool-Clients angezeigten News zu editieren.

- Aktive News + {{activeNews}}
- - + +
- - + +
-

Letzte Aktualisierung: {{latestDate}}

- - Leeren +

{{latestUpdate}}: {{latestDate}}

+
-- cgit v1.2.3-55-g7522