Merge pull request #251 from Focuslinkstech/master

Customer can set their own language
This commit is contained in:
iBNu Maksum 2024-08-15 15:08:08 +07:00 committed by GitHub
commit e96a9677bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 102 additions and 11 deletions

View File

@ -131,17 +131,26 @@ if ((!empty($radius_user) && $config['radius_enable']) || _post('radius_enable')
}
if (empty($config['language'])) {
$config['language'] = 'english';
// Check if the user has selected a language
if (!empty($_SESSION['user_language'])) {
$config['language'] = $_SESSION['user_language'];
}
$lan_file = $root_path . File::pathFixer('system/lan/' . $config['language'] . '.json');
if (file_exists($lan_file)) {
$_L = json_decode(file_get_contents($lan_file), true);
$_SESSION['Lang'] = $_L;
if (empty($_SESSION['Lang'])) {
if (empty($config['language'])) {
$config['language'] = 'english';
}
$lan_file = $root_path . File::pathFixer('system/lan/' . $config['language'] . '.json');
if (file_exists($lan_file)) {
$_L = json_decode(file_get_contents($lan_file), true);
$_SESSION['Lang'] = $_L;
} else {
$_L['author'] = 'Auto Generated by iBNuX Script';
$_SESSION['Lang'] = $_L;
file_put_contents($lan_file, json_encode($_L));
}
} else {
$_L['author'] = 'Auto Generated by iBNuX Script';
$_SESSION['Lang'] = $_L;
file_put_contents($lan_file, json_encode($_L));
$_L = $_SESSION['Lang'];
}

View File

@ -10,7 +10,12 @@ class Lang
{
public static function T($key)
{
global $_L, $lan_file, $config;
global $_L, $lan_file, $root_path, $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']);
}

View File

@ -46,6 +46,7 @@ $ui->assign('_domain', str_replace('www.', '', parse_url(APP_URL, PHP_URL_HOST))
$ui->assign('_url', APP_URL . '/?_route=');
$ui->assign('_path', __DIR__);
$ui->assign('_c', $config);
$ui->assign('user_language', $_SESSION['user_language']);
$ui->assign('UPLOAD_PATH', str_replace($root_path, '', $UPLOAD_PATH));
$ui->assign('CACHE_PATH', str_replace($root_path, '', $CACHE_PATH));
$ui->assign('PAGES_PATH', str_replace($root_path, '', $PAGES_PATH));

View File

@ -37,7 +37,7 @@ switch ($action) {
}
$user->password = $npass;
$turs = ORM::for_table('tbl_user_recharges')->where('customer_id', $user['id'])->find_many();
foreach($turs as $tur) {
foreach ($turs as $tur) {
// if has active plan, change the password to devices
if ($tur['status'] == 'on') {
$p = ORM::for_table('tbl_plans')->where('id', $tur['plan_id'])->find_one();
@ -239,6 +239,29 @@ switch ($action) {
r2(U . 'accounts/profile', 's', Lang::T('Phone number updated successfully'));
break;
case 'language-update-post':
global $root_path;
if (!empty($_POST['language'])) {
$selected_language = $_POST['language'];
$_SESSION['user_language'] = $selected_language;
$lan_file = $root_path . File::pathFixer('system/lan/' . $selected_language . '.json');
if (file_exists($lan_file)) {
$_L = json_decode(file_get_contents($lan_file), true);
$_SESSION['Lang'] = $_L;
} else {
$_L['author'] = 'Auto Generated by iBNuX Script';
$_SESSION['Lang'] = $_L;
file_put_contents($lan_file, json_encode($_L));
}
r2($_SERVER['HTTP_REFERER'], 's', Lang::T('Languge set to ' . $selected_language));
}
break;
default:
$ui->display('a404.tpl');
}

View File

@ -66,6 +66,15 @@
transform: rotate(360deg);
}
}
.dropdown-menu .dropdown-item {
margin-bottom: 5px;
}
.dropdown-menu .dropdown-item button {
margin: 0;
padding: 10px;
}
</style>
{if isset($xheader)}
@ -87,6 +96,50 @@
</a>
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li class="dropdown tasks-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">
<i class="fa fa-flag-o"></i> <span class="d-none d-sm-inline">Language</span>
</a>
<ul class="dropdown-menu">
<form method="post" action="{$app_url}accounts/language-update-post">
<li
class="dropdown-item">
<button class="btn btn-block btn-{if $user_language == 'english'}success {else}primary{/if} btn-xs" type="submit" name="language"
value="english">
{Lang::T('English')}
</button>
</li>
<li
class="dropdown-item">
<button class="btn btn-block btn-{if $user_language == 'indonesia'}success {else}primary{/if} btn-xs" type="submit" name="language"
value="indonesia">
{Lang::T('Indonesian')}
</button>
</li>
<li
class="dropdown-item">
<button class="btn btn-block btn-{if $user_language == 'spanish'}success {else}primary{/if} btn-xs" type="submit" name="language"
value="spanish">
{Lang::T('Spanish')}
</button>
</li>
<li
class="dropdown-item">
<button class="btn btn-block btn-{if $user_language == 'arabic'}success {else}primary{/if} btn-xs" type="submit" name="language"
value="arabic">
{Lang::T('Arabic')}
</button>
</li>
<li
class="dropdown-item">
<button class="btn btn-block btn-{if $user_language == 'turkish'}success {else}primary{/if} btn-xs" type="submit" name="language"
value="turkish">
{Lang::T('Turkish')}
</button>
</li>
</form>
</ul>
</li>
<li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<i class="fa fa-envelope-o"></i>