attributes->get('lottery_locale') ?? LotteryLocale::resolve($request)); $key = 'wallet.'.$code; $msg = trans($key, [], $locale); if ($msg !== $key) { return $msg; } return trans($key, [], $fallback); } /** * 取 SSO 鉴权类错误的用户可见文案(与 ApiResponse 的 msg 对应)。 * * @param int $code {@see ErrorCode} 玩家 SSO 段(8001–8005) */ public static function sso(Request $request, int $code): string { $fallback = (string) config('lottery.locales.fallback', 'en'); $locale = (string) ($request->attributes->get('lottery_locale') ?? LotteryLocale::resolve($request)); $key = 'sso.'.$code; // 对应 lang/{locale}/sso.php 内键名,如 '8001' $msg = trans($key, [], $locale); // Laravel 无键时返回整条 key 字符串,此时改用 fallback 语言再试一次 if ($msg !== $key) { return $msg; } return trans($key, [], $fallback); } }