cakePHP 3.3国际化

时间:2016-11-26 21:58:15

标签: cakephp cakephp-3.0

如果文本在数组中,我如何设置多种语言?

我知道如果我使用这个

<?= __('username')?>

并在目录/src/Locale/de_DE/default.po中 我写了以下

msgid "username"
msgstr "benutzer"

如果我将语言设置为de_DE(德语)

,它会将用户名更改为benutzer


但如果我有这个怎么办

<?= $this->Form->input('password',['label' =>'Password']); ?>

我想更改标签密码

1 个答案:

答案 0 :(得分:2)

简单:

$this->Form->input('password', ['label' => __('Password')]);

__()函数只返回翻译后的字符串(more info)。在您的示例中,您使用了

<?= ... ?>

相当于

<?php echo ... ?>