json中字符串的php gettext

json中字符串的php gettext,php,gettext,Php,Gettext,如何实现下面“message”的gettext echo(“”) $output = array( 'returnCode' => '0', 'message' => "Sorry, an error has occured. Please try again." ); echo json_encode($output); 我试过了 $output = array(

如何实现下面“message”的gettext echo(“”)

$output = array(
                'returnCode'    => '0',
                'message'   => "Sorry, an error has occured. Please try again."
            );
echo json_encode($output);
我试过了

$output = array(
                    'returnCode'    => '0',
                    'message'   => echo _("Sorry, an error has occured. Please try again.")
                );

当然,如果您只想回显索引
消息,它会返回一个错误

,您可以这样做:

$output = array(
            'returnCode'    => '0',
            'message'   => "Sorry, an error has occured. Please try again."
        );

$message = $output['message'];

echo $message; //output: Sorry, an error has occured. Please try again.
json格式的回声:

echo json_encode($message);

根据您将要执行的操作,在编码为json之前,您应该对变量进行修改

谢谢。。不管怎样我也注意到了事实上。。证明我需要一些睡眠。。。不管怎样,你为什么不把你的评论作为答案呢?至少我能记下来