对搜索返回的消息做中英双版本
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user