多语言
This commit is contained in:
@@ -8,6 +8,7 @@ use plugin\admin\app\model\Location;
|
||||
use plugin\admin\app\controller\Crud;
|
||||
use support\exception\BusinessException;
|
||||
use util\Util;
|
||||
use support\Log;
|
||||
|
||||
/**
|
||||
* 仓库/港口
|
||||
@@ -35,7 +36,22 @@ class LocationController extends Crud
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
return view('location/index');
|
||||
// 获取当前语言
|
||||
$lang = session('lang', 'zh-cn');
|
||||
Log::info('Current language', ['lang' => $lang]);
|
||||
|
||||
// 加载语言文件
|
||||
$location_translations = include __DIR__ . "/../lang/{$lang}/location.php";
|
||||
$common_translations = include __DIR__ . "/../lang/{$lang}/common.php";
|
||||
|
||||
// 合并翻译
|
||||
$translations = array_merge($location_translations, $common_translations);
|
||||
Log::info('Loaded translations', ['keys' => array_keys($translations)]);
|
||||
|
||||
return view('location/index', [
|
||||
'lang' => $lang,
|
||||
'translations' => $translations
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,7 +65,20 @@ class LocationController extends Crud
|
||||
if ($request->method() === 'POST') {
|
||||
return parent::insert($request);
|
||||
}
|
||||
return view('location/insert');
|
||||
// 获取当前语言
|
||||
$lang = session('lang', 'zh-cn');
|
||||
|
||||
// 加载语言文件
|
||||
$location_translations = include __DIR__ . "/../lang/{$lang}/location.php";
|
||||
$common_translations = include __DIR__ . "/../lang/{$lang}/common.php";
|
||||
|
||||
// 合并翻译
|
||||
$translations = array_merge($location_translations, $common_translations);
|
||||
|
||||
return view('location/insert', [
|
||||
'lang' => $lang,
|
||||
'translations' => $translations
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +92,20 @@ class LocationController extends Crud
|
||||
if ($request->method() === 'POST') {
|
||||
return parent::update($request);
|
||||
}
|
||||
return view('location/update');
|
||||
// 获取当前语言
|
||||
$lang = session('lang', 'zh-cn');
|
||||
|
||||
// 加载语言文件
|
||||
$location_translations = include __DIR__ . "/../lang/{$lang}/location.php";
|
||||
$common_translations = include __DIR__ . "/../lang/{$lang}/common.php";
|
||||
|
||||
// 合并翻译
|
||||
$translations = array_merge($location_translations, $common_translations);
|
||||
|
||||
return view('location/update', [
|
||||
'lang' => $lang,
|
||||
'translations' => $translations
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user