fixes from u1 (default login + i18n)

This commit is contained in:
Serghey Rodin 2016-06-27 01:39:34 +03:00
commit 4b8a2c3f38
2 changed files with 89 additions and 66 deletions

View file

@ -67,6 +67,7 @@ function detect_user_language($fallback='en') {
return $user_lang;
}
// Sort Accept-Language by `q` value
$accept_langs = explode(',', preg_replace('/\s/', '', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
$accept_langs_sorted = array() ;
@ -110,3 +111,13 @@ function detect_user_language($fallback='en') {
$user_lang = $fallback;
return $user_lang;
}
/**
* Detects user language .
* @param string Fallback language (default: 'en')
* @return string Language code (such as 'en' and 'ja')
*/
function detect_login_language(){
}

View file

@ -94,7 +94,19 @@ foreach ($sys_arr as $key => $value) {
}
// Detect language
if (empty($_SESSION['language'])) $_SESSION['language'] = detect_user_language();
if (empty($_SESSION['language'])) {
$output = '';
exec (VESTA_CMD."v-list-sys-config json", $output, $return_var);
$config = json_decode(implode('', $output), true);
$lang = $config['config']['LANGUAGE'];
$output = '';
exec (VESTA_CMD."v-list-sys-languages json", $output, $return_var);
$languages = json_decode(implode('', $output), true);
if(in_array($lang, $languages)){
$_SESSION['language'] = $lang;
}
}
require_once($_SERVER['DOCUMENT_ROOT'].'/inc/i18n/'.$_SESSION['language'].'.php');
require_once('../templates/header.html');