mirror of
https://github.com/myvesta/vesta
synced 2025-08-20 05:14:10 -07:00
fixes from u1 (default login + i18n)
This commit is contained in:
parent
5edfe8dd32
commit
4b8a2c3f38
2 changed files with 89 additions and 66 deletions
|
@ -67,6 +67,7 @@ function detect_user_language($fallback='en') {
|
||||||
return $user_lang;
|
return $user_lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Sort Accept-Language by `q` value
|
// Sort Accept-Language by `q` value
|
||||||
$accept_langs = explode(',', preg_replace('/\s/', '', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
|
$accept_langs = explode(',', preg_replace('/\s/', '', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE'])));
|
||||||
$accept_langs_sorted = array() ;
|
$accept_langs_sorted = array() ;
|
||||||
|
@ -110,3 +111,13 @@ function detect_user_language($fallback='en') {
|
||||||
$user_lang = $fallback;
|
$user_lang = $fallback;
|
||||||
return $user_lang;
|
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(){
|
||||||
|
|
||||||
|
}
|
|
@ -94,7 +94,19 @@ foreach ($sys_arr as $key => $value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect language
|
// 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($_SERVER['DOCUMENT_ROOT'].'/inc/i18n/'.$_SESSION['language'].'.php');
|
||||||
require_once('../templates/header.html');
|
require_once('../templates/header.html');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue