initial gettext integration
This commit is contained in:
parent
33b97e3ad3
commit
96a263f712
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
$locales = array(
|
||||||
|
'de_DE.UTF-8' => "Deutsch",
|
||||||
|
'en_US.UTF-8' => "English"
|
||||||
|
);
|
||||||
|
|
||||||
|
$default_locale = 'en_US.UTF-8';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes gettext for internationalization and updates the sessions locale to use for translation.
|
||||||
|
*/
|
||||||
|
function gettext_init() {
|
||||||
|
global $locales, $default_locale;
|
||||||
|
|
||||||
|
if (isset($_REQUEST['set_locale']) && in_array($_REQUEST['set_locale'], array_keys($locales)))
|
||||||
|
$_SESSION['locale'] = $_REQUEST['set_locale'];
|
||||||
|
elseif (! isset($_SESSION['locale']))
|
||||||
|
$_SESSION['locale'] = $default_locale;
|
||||||
|
|
||||||
|
putenv('LC_ALL=' . $_SESSION['locale']);
|
||||||
|
setlocale(LC_ALL, $_SESSION['locale']);
|
||||||
|
bindtextdomain('default', '../locale');
|
||||||
|
bind_textdomain_codeset('default', 'UTF-8');
|
||||||
|
textdomain('default');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders language selection.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function make_langselect() {
|
||||||
|
global $locales;
|
||||||
|
$URL = $_SERVER["REQUEST_URI"] . (strpos($_SERVER["REQUEST_URI"], "?") > 0 ? '&' : '?') . "set_locale=";
|
||||||
|
|
||||||
|
$html = '<p class="content">';
|
||||||
|
foreach ($locales as $locale => $name)
|
||||||
|
$html .= '<a class="sprache" href="' . htmlspecialchars($URL) . $locale . '"><img src="pic/flag/' . $locale . '.png" alt="' . $name . '" title="' . $name . '"></a>';
|
||||||
|
$html .= '</p>';
|
||||||
|
return '<nav class="container"><h4>' . _("Language") . '</h4>' . $html . '</nav>';
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -9,7 +9,7 @@ function guest_register() {
|
||||||
$nick = "";
|
$nick = "";
|
||||||
$lastname = "";
|
$lastname = "";
|
||||||
$prename = "";
|
$prename = "";
|
||||||
$age = 23;
|
$age = "";
|
||||||
$tel = "";
|
$tel = "";
|
||||||
$dect = "";
|
$dect = "";
|
||||||
$mobile = "";
|
$mobile = "";
|
||||||
|
|
|
@ -13,24 +13,24 @@ function page_link_to_absolute($page) {
|
||||||
*/
|
*/
|
||||||
function header_toolbar() {
|
function header_toolbar() {
|
||||||
global $p, $privileges, $user;
|
global $p, $privileges, $user;
|
||||||
|
|
||||||
$toolbar_items = array();
|
$toolbar_items = array();
|
||||||
|
|
||||||
if(in_array('register', $privileges))
|
if (in_array('register', $privileges))
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'register', "Register", $p == 'register');
|
$toolbar_items[] = toolbar_item_link(page_link_to('register'), 'register', "Register", $p == 'register');
|
||||||
|
|
||||||
if(in_array('user_myshifts', $privileges))
|
if (in_array('user_myshifts', $privileges))
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('user_myshifts'), 'engel', $user['Nick'], $p == 'user_myshifts');
|
$toolbar_items[] = toolbar_item_link(page_link_to('user_myshifts'), 'engel', $user['Nick'], $p == 'user_myshifts');
|
||||||
|
|
||||||
if(in_array('user_settings', $privileges))
|
if (in_array('user_settings', $privileges))
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('user_settings'), 'settings', "Settings", $p == 'user_settings');
|
$toolbar_items[] = toolbar_item_link(page_link_to('user_settings'), 'settings', "Settings", $p == 'user_settings');
|
||||||
|
|
||||||
if(in_array('login', $privileges))
|
if (in_array('login', $privileges))
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('login'), 'login', "Login", $p == 'login');
|
$toolbar_items[] = toolbar_item_link(page_link_to('login'), 'login', "Login", $p == 'login');
|
||||||
|
|
||||||
if(in_array('logout', $privileges))
|
if (in_array('logout', $privileges))
|
||||||
$toolbar_items[] = toolbar_item_link(page_link_to('logout'), 'logout', "Logout", $p == 'logout');
|
$toolbar_items[] = toolbar_item_link(page_link_to('logout'), 'logout', "Logout", $p == 'logout');
|
||||||
|
|
||||||
return toolbar($toolbar_items);
|
return toolbar($toolbar_items);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,11 +38,11 @@ function make_navigation() {
|
||||||
global $p;
|
global $p;
|
||||||
global $privileges;
|
global $privileges;
|
||||||
$menu = "";
|
$menu = "";
|
||||||
|
|
||||||
$specials = array(
|
$specials = array(
|
||||||
"faq"
|
"faq"
|
||||||
);
|
);
|
||||||
|
|
||||||
$pages = array(
|
$pages = array(
|
||||||
"news",
|
"news",
|
||||||
"user_meetings",
|
"user_meetings",
|
||||||
|
@ -65,28 +65,28 @@ function make_navigation() {
|
||||||
"admin_faq",
|
"admin_faq",
|
||||||
"admin_language",
|
"admin_language",
|
||||||
"admin_import",
|
"admin_import",
|
||||||
"admin_log"
|
"admin_log"
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ($pages as $page)
|
foreach ($pages as $page)
|
||||||
if (in_array($page, $privileges) || in_array($page, $specials))
|
if (in_array($page, $privileges) || in_array($page, $specials))
|
||||||
$menu .= '<li' . ($page == $p ? ' class="selected"' : '') . '><a href="' . page_link_to($page) . '">' . Get_Text($page) . '</a></li>';
|
$menu .= '<li' . ($page == $p ? ' class="selected"' : '') . '><a href="' . page_link_to($page) . '">' . Get_Text($page) . '</a></li>';
|
||||||
|
|
||||||
return '<nav><ul>' . $menu . '</ul></nav>';
|
return '<nav><ul>' . $menu . '</ul></nav>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_navigation_for($name, $pages) {
|
function make_navigation_for($name, $pages) {
|
||||||
global $privileges, $p;
|
global $privileges, $p;
|
||||||
|
|
||||||
$specials = array(
|
$specials = array(
|
||||||
"faq"
|
"faq"
|
||||||
);
|
);
|
||||||
|
|
||||||
$menu = "";
|
$menu = "";
|
||||||
foreach ($pages as $page)
|
foreach ($pages as $page)
|
||||||
if (in_array($page, $privileges) || in_array($page, $specials))
|
if (in_array($page, $privileges) || in_array($page, $specials))
|
||||||
$menu .= '<li' . ($page == $p ? ' class="selected"' : '') . '><a href="' . page_link_to($page) . '">' . Get_Text($page) . '</a></li>';
|
$menu .= '<li' . ($page == $p ? ' class="selected"' : '') . '><a href="' . page_link_to($page) . '">' . Get_Text($page) . '</a></li>';
|
||||||
|
|
||||||
if ($menu != "")
|
if ($menu != "")
|
||||||
$menu = '<nav class="container"><h4>' . $name . '</h4><ul class="content">' . $menu . '</ul></nav>';
|
$menu = '<nav class="container"><h4>' . $name . '</h4><ul class="content">' . $menu . '</ul></nav>';
|
||||||
return $menu;
|
return $menu;
|
||||||
|
@ -96,14 +96,4 @@ function make_menu() {
|
||||||
return make_navigation() . make_langselect();
|
return make_navigation() . make_langselect();
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_langselect() {
|
|
||||||
if (strpos($_SERVER["REQUEST_URI"], "?") > 0)
|
|
||||||
$URL = $_SERVER["REQUEST_URI"] . "&SetLanguage=";
|
|
||||||
else
|
|
||||||
$URL = $_SERVER["REQUEST_URI"] . "?SetLanguage=";
|
|
||||||
|
|
||||||
$html = '<p class="content"><a class="sprache" href="' . htmlspecialchars($URL) . 'DE"><img src="pic/flag/de.png" alt="DE" title="Deutsch"></a>';
|
|
||||||
$html .= '<a class="sprache" href="' . htmlspecialchars($URL) . 'EN"><img src="pic/flag/en.png" alt="EN" title="English"></a></p>';
|
|
||||||
return '<nav class="container"><h4>' . Get_Text("Sprache") . '</h4>' . $html . '</nav>';
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,25 @@
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Engelsystem 2.0\n"
|
||||||
|
"POT-Creation-Date: 2013-11-25 19:11+0100\n"
|
||||||
|
"PO-Revision-Date: 2013-11-25 19:11+0100\n"
|
||||||
|
"Last-Translator: msquare <msquare@notrademark.de>\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"Language: de_DE\n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
"X-Generator: Poedit 1.5.7\n"
|
||||||
|
"X-Poedit-KeywordsList: _;gettext;gettext_noop\n"
|
||||||
|
"X-Poedit-Basepath: .\n"
|
||||||
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
"X-Poedit-SourceCharset: UTF-8\n"
|
||||||
|
"X-Poedit-SearchPath-0: /Users/msquare/workspace/projects/engelsystem\n"
|
||||||
|
"X-Poedit-SearchPath-1: .\n"
|
||||||
|
|
||||||
|
#: /Users/msquare/workspace/projects/engelsystem/includes/helper/internationalization_helper.php:40
|
||||||
|
msgid "Language"
|
||||||
|
msgstr "Sprache"
|
||||||
|
|
||||||
|
#~ msgid "asdf"
|
||||||
|
#~ msgstr "fdsa"
|
|
@ -33,6 +33,7 @@ a {
|
||||||
}
|
}
|
||||||
|
|
||||||
.error,.success,.info {
|
.error,.success,.info {
|
||||||
|
color: #fff;
|
||||||
background-color: #333;
|
background-color: #333;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ require_once ('includes/view/Shifts_view.php');
|
||||||
require_once ('includes/view/Sprache_view.php');
|
require_once ('includes/view/Sprache_view.php');
|
||||||
require_once ('includes/view/User_view.php');
|
require_once ('includes/view/User_view.php');
|
||||||
|
|
||||||
|
require_once ('includes/helper/internationalization_helper.php');
|
||||||
require_once ('includes/helper/message_helper.php');
|
require_once ('includes/helper/message_helper.php');
|
||||||
require_once ('includes/helper/error_helper.php');
|
require_once ('includes/helper/error_helper.php');
|
||||||
|
|
||||||
|
@ -30,6 +31,8 @@ require_once ('includes/pages/user_messages.php');
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
gettext_init();
|
||||||
|
|
||||||
sql_connect($config['host'], $config['user'], $config['pw'], $config['db']);
|
sql_connect($config['host'], $config['user'], $config['pw'], $config['db']);
|
||||||
|
|
||||||
load_auth();
|
load_auth();
|
||||||
|
@ -37,7 +40,7 @@ load_auth();
|
||||||
// JSON Authorisierung gewünscht?
|
// JSON Authorisierung gewünscht?
|
||||||
if (isset($_REQUEST['auth']))
|
if (isset($_REQUEST['auth']))
|
||||||
json_auth_service();
|
json_auth_service();
|
||||||
|
|
||||||
// Gewünschte Seite/Funktion
|
// Gewünschte Seite/Funktion
|
||||||
$p = isset($user) ? "news" : "login";
|
$p = isset($user) ? "news" : "login";
|
||||||
if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && ($_REQUEST['p'] == 'stats' || (sql_num_query("SELECT * FROM `Privileges` WHERE `name`='" . sql_escape($_REQUEST['p']) . "' LIMIT 1") > 0)))
|
if (isset($_REQUEST['p']) && preg_match("/^[a-z0-9_]*$/i", $_REQUEST['p']) && ($_REQUEST['p'] == 'stats' || (sql_num_query("SELECT * FROM `Privileges` WHERE `name`='" . sql_escape($_REQUEST['p']) . "' LIMIT 1") > 0)))
|
||||||
|
@ -163,26 +166,26 @@ elseif (in_array($p, $privileges)) {
|
||||||
// Hinweis für ungelesene Nachrichten
|
// Hinweis für ungelesene Nachrichten
|
||||||
if (isset($user) && $p != "user_messages")
|
if (isset($user) && $p != "user_messages")
|
||||||
$content = user_unread_messages() . $content;
|
$content = user_unread_messages() . $content;
|
||||||
|
|
||||||
// Hinweis für Engel, die noch nicht angekommen sind
|
// Hinweis für Engel, die noch nicht angekommen sind
|
||||||
if (isset($user) && $user['Gekommen'] == 0)
|
if (isset($user) && $user['Gekommen'] == 0)
|
||||||
$content = error("You are not marked as arrived. Please go to heaven's desk, get your angel badge and/or tell them that you arrived already.", true) . $content;
|
$content = error("You are not marked as arrived. Please go to heaven's desk, get your angel badge and/or tell them that you arrived already.", true) . $content;
|
||||||
|
|
||||||
// Erzengel Hinweis für unbeantwortete Fragen
|
// Erzengel Hinweis für unbeantwortete Fragen
|
||||||
if (isset($user) && $p != "admin_questions")
|
if (isset($user) && $p != "admin_questions")
|
||||||
$content = admin_new_questions() . $content;
|
$content = admin_new_questions() . $content;
|
||||||
|
|
||||||
// Erzengel Hinweis für freizuschaltende Engeltypen
|
// Erzengel Hinweis für freizuschaltende Engeltypen
|
||||||
if (isset($user) && $p != "admin_user_angeltypes")
|
if (isset($user) && $p != "admin_user_angeltypes")
|
||||||
$content = admin_new_user_angeltypes() . $content;
|
$content = admin_new_user_angeltypes() . $content;
|
||||||
|
|
||||||
echo template_render('../templates/layout.html', array (
|
echo template_render('../templates/layout.html', array(
|
||||||
'theme' => isset($user) ? $user['color'] : $default_theme,
|
'theme' => isset($user) ? $user['color'] : $default_theme,
|
||||||
'title' => $title,
|
'title' => $title,
|
||||||
'atom_link' => ($p == 'news' || $p == 'user_meetings') ? '<link href="' . page_link_to('atom') . (($p == 'user_meetings') ? '&meetings=1' : '') . '&key=' . $user['api_key'] . '" type="application/atom+xml" rel="alternate" title="Atom Feed">' : '',
|
'atom_link' => ($p == 'news' || $p == 'user_meetings') ? '<link href="' . page_link_to('atom') . (($p == 'user_meetings') ? '&meetings=1' : '') . '&key=' . $user['api_key'] . '" type="application/atom+xml" rel="alternate" title="Atom Feed">' : '',
|
||||||
'menu' => make_menu(),
|
'menu' => make_menu(),
|
||||||
'content' => $content,
|
'content' => $content,
|
||||||
'header_toolbar' => header_toolbar()
|
'header_toolbar' => header_toolbar()
|
||||||
));
|
));
|
||||||
|
|
||||||
counter();
|
counter();
|
||||||
|
|
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 545 B |
Before Width: | Height: | Size: 599 B After Width: | Height: | Size: 599 B |
Loading…
Reference in New Issue