2018-07-29 19:54:30 +02:00
|
|
|
<?php
|
|
|
|
$config = parse_ini_file(__DIR__.'/config/config.ini',true);
|
|
|
|
$locale = '';
|
2018-08-04 15:52:34 +02:00
|
|
|
if(isset($_COOKIE['language'])) $locale = $_COOKIE['language'];
|
2018-10-02 19:50:54 +02:00
|
|
|
else if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
2018-08-04 15:52:34 +02:00
|
|
|
$langcode = Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
2018-10-02 20:17:02 +02:00
|
|
|
if(file_exists(__DIR__.'/locale/'.$langcode)) $locale = $langcode;
|
2018-08-04 15:52:34 +02:00
|
|
|
else if(file_exists(__DIR__.'/locale/'.explode("_",$langcode)[0])) $locale = explode("_",$langcode)[0];
|
|
|
|
else $locale = $config['App']['default_language'];
|
2018-07-29 19:54:30 +02:00
|
|
|
}
|
2018-10-02 19:50:54 +02:00
|
|
|
else $locale = $config['App']['default_language'];
|
2018-07-29 19:54:30 +02:00
|
|
|
if(function_exists("putenv")) {
|
|
|
|
putenv('LC_ALL='.$locale);
|
|
|
|
}
|
2018-08-04 15:52:34 +02:00
|
|
|
if(!setlocale(LC_ALL,$locale)) {
|
|
|
|
if(!setlocale(LC_ALL,$locale.".UTF-8")) setlocale(LC_ALL,0);
|
|
|
|
}
|
2018-07-29 19:54:30 +02:00
|
|
|
bindtextdomain('messages',__DIR__.'/locale');
|
|
|
|
bind_textdomain_codeset('messages','UTF-8');
|
|
|
|
textdomain('messages');
|
2018-08-04 15:52:34 +02:00
|
|
|
if(!function_exists('pgettext')) {
|
|
|
|
function pgettext($context,$msgid) {
|
2018-07-29 19:54:30 +02:00
|
|
|
$contextString = "{$context}\004{$msgid}";
|
|
|
|
$translation = _($contextString);
|
|
|
|
if($translation == $contextString) return $msgid;
|
|
|
|
else return $translation;
|
|
|
|
}
|
|
|
|
}
|
2018-08-04 15:52:34 +02:00
|
|
|
if(strstr($locale,"_")) $lang = explode('_',$locale)[0];
|
|
|
|
else $lang = $locale;
|
2018-07-29 19:54:30 +02:00
|
|
|
?>
|