initial gettext integration
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>';
|
||||
}
|
||||
|
||||
?>
|
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"
|
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