对搜索返回的消息做中英双版本

This commit is contained in:
2026-04-28 15:22:50 +08:00
parent 85133ee92b
commit 9bc439ea5e
32 changed files with 575 additions and 183 deletions

View File

@@ -76,6 +76,14 @@ abstract class BaseController
*/
protected function result(string $msg, mixed $data = null, int $code = 0, array $header = []): Response
{
// 统一对返回 msg 做多语言翻译:若 $msg 为语言 key英文则按请求语言输出
// 若无对应翻译,则保持原样返回。
if ($msg !== '' && function_exists('__')) {
$translated = __($msg);
if (is_string($translated) && $translated !== '') {
$msg = $translated;
}
}
$body = [
'code' => $code,
'msg' => $msg,