CakePHP 3 : 如何准备 cakephp 表分页标题进行本地化?



我的表头看下面

<th scope="col"><?= $this->Paginator->sort('name')?></th>

生成 POT 文件后,"名称"尚未生成"msgid"和"msgstr"。

我已经尝试过下面的代码,但结果是一样的。

<th scope="col"><?= __($this->Paginator->sort('name')) ?></th>

在 POT 文件生成之前我将如何准备它?

你可以这样写你的标签

<th scope="col"><?= $this->Paginator->sort('name',__('Name')) ?></th>

排序函数中的键的名称用于对记录集进行排序。您不能使用它在 POT 文件中生成"msgid"和"msgstr"。

你可以生成msgid和msgstr,只需在其他地方定义它,如

<? = __('name') ?>;
PaginatorHelper::sort($key, $title = null, $options = array())

供您参考: https://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html

最新更新