代码之家  ›  专栏  ›  技术社区  ›  Satu Sultana

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

  •  0
  • Satu Sultana  · 技术社区  · 6 年前

    我的表标题如下

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

    生成pot文件后,“name”没有生成“msgid”和“msgstr”。

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

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

    如何在pot文件生成之前准备它?

    2 回复  |  直到 6 年前
        1
  •  0
  •   Alimon Karim    6 年前

    你可以把标签写得像

    <th scope="col"><?= $this->Paginator->sort('name',__('Name')) ?></th>
    
        2
  •  0
  •   Sehdev    6 年前

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

    您可以通过在其他地方定义msgid和msgstr来生成msgid和msgstr,比如

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

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