【问题标题】:translate tabledata in twig在树枝中翻译表格数据
【发布时间】:2016-08-01 18:13:50
【问题描述】:

我以这种方式用数据填充表格

  <tbody>
     {% for post in posts %}

            <tr>

              <td>{{ post.title }}</td>

              <td>{{ post.status }}</td>                

          </tr>
   {% endfor %}
  </tbody>

我需要从状态转换值,但它不起作用。 post.status 在数据库 PO_DRAFTPO_ACCEPT 中只有 2 个值,我需要它翻译。是否可以? 这种方式我试过了,但是错了

 <td>{% trans %}{{ post.status }}{% endtrans %}</td>

【问题讨论】:

标签: php html symfony twig language-translation


【解决方案1】:

Twig 的 i18n documentation 提到了一个 trans 过滤器,所以也许这会起作用?

{{ post.status | trans }}

【讨论】:

  • 它也不起作用。我收到此错误:trans 标记内的消息必须是第 89 行的 components/post/search.html.twig 中的简单文本。
猜你喜欢
  • 2018-07-23
  • 2015-03-08
  • 1970-01-01
  • 1970-01-01
  • 2019-05-07
  • 1970-01-01
  • 2014-05-23
  • 2019-07-18
  • 1970-01-01
相关资源
最近更新 更多