多语言

This commit is contained in:
2025-05-06 17:16:37 +08:00
parent 07d628140e
commit 5ef4d9d754
32 changed files with 1596 additions and 920 deletions
@@ -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
]);
}
/**