forked from kevinowino869/mitrobill
Auto Translate Language
This commit is contained in:
@ -148,11 +148,20 @@ function _notify($msg, $type = 'e')
|
||||
if (empty($config['language'])) {
|
||||
$config['language'] = 'english';
|
||||
}
|
||||
$lan_file = File::pathFixer('system/lan/' . $config['language'] . '/common.lan.php');
|
||||
if (file_exists($lan_file)) {
|
||||
require $lan_file;
|
||||
|
||||
if (empty($_SESSION['Lang'])) {
|
||||
$lan_file = File::pathFixer('system/lan/' . $config['language'] . '.json');
|
||||
if (file_exists($lan_file)) {
|
||||
$_L = json_decode(file_get_contents($lan_file), true);
|
||||
} else {
|
||||
$_L['nux_created_by'] = 'Auto Generated by iBNuX Script';
|
||||
$_SESSION['Lang'] = $_L;
|
||||
if (file_exists($lan_file)) {
|
||||
file_put_contents(File::pathFixer('system/lan/' . $config['language'] . '/common.lan.json'), json_encode($_L));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
die("$lan_file not found");
|
||||
$_L = $_SESSION['Lang'];
|
||||
}
|
||||
|
||||
$ui = new Smarty();
|
||||
@ -253,21 +262,7 @@ function _log($description, $type = '', $userid = '0')
|
||||
|
||||
function Lang($key)
|
||||
{
|
||||
global $_L, $lan_file;
|
||||
if (!empty($_L[$key])) {
|
||||
return $_L[$key];
|
||||
}
|
||||
$val = $key;
|
||||
$key = alphanumeric($key, " ");
|
||||
if (!empty($_L[$key])) {
|
||||
return $_L[$key];
|
||||
} else if (!empty($_L[str_replace(' ', '_', $key)])) {
|
||||
return $_L[str_replace(' ', '_', $key)];
|
||||
} else {
|
||||
$key = str_replace(' ', '_', $key);
|
||||
file_put_contents($lan_file, "$" . "_L['$key'] = '" . addslashes($val) . "';\n", FILE_APPEND);
|
||||
return $val;
|
||||
}
|
||||
return Lang::T($key);
|
||||
}
|
||||
|
||||
function alphanumeric($str, $tambahan = "")
|
||||
|
Reference in New Issue
Block a user