CakePHP 3:如何为本地化准备 cakephp table paginate header?

CakePHP 3 : How to prepare cakephp table paginate header for localization?

我的tableheader往下看

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

生成POT文件后'name'还没有生成'msgid'和'msgstr'。

我试过像下面的代码但结果是一样的。

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

生成 POT 文件前如何准备?

sort函数中的key名称用于对记录集进行排序。您不能使用它在您的 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

你可以这样写你的标签

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