Fix Lang function again

This commit is contained in:
Ibnu Maksum
2024-10-10 10:24:01 +07:00
parent 2522f3112e
commit b1919555e5
6 changed files with 77 additions and 32 deletions

View File

@ -10,15 +10,8 @@ class Lang
{
public static function T($key)
{
global $_L, $lan_file, $root_path, $config;
global $_L, $lan_file, $config;
if (empty($lan_file)) {
$lan_file = $root_path . File::pathFixer('system/lan/' . $config['language'] . '.json');
}
if (is_array($_SESSION['Lang'])) {
$_L = array_merge($_L, $_SESSION['Lang']);
}
$key = preg_replace('/\s+/', ' ', $key);
if (!empty($_L[$key])) {
return $_L[$key];
@ -41,8 +34,7 @@ class Lang
}
}
$_L[$key] = $val;
$_SESSION['Lang'][$key] = $val;
file_put_contents($lan_file, json_encode($_SESSION['Lang'], JSON_PRETTY_PRINT));
file_put_contents($lan_file, json_encode($_L, JSON_PRETTY_PRINT));
return $val;
}
}