refactor: 重构语言协商中间件,简化语言解析逻辑并增强异常处理,更新相关配置以支持多环境开发

This commit is contained in:
2026-05-08 17:40:09 +08:00
parent 85e57782cc
commit e478597d13
11 changed files with 295 additions and 54 deletions

View File

@@ -22,7 +22,7 @@ final class LotteryMessage
public static function sso(Request $request, int $code): string
{
$fallback = (string) config('lottery.locales.fallback', 'en');
$locale = (string) ($request->attributes->get('lottery_locale') ?? $fallback);
$locale = (string) ($request->attributes->get('lottery_locale') ?? LotteryLocale::resolve($request));
$key = 'sso.'.$code; // 对应 lang/{locale}/sso.php 内键名,如 '8001'
$msg = trans($key, [], $locale);