【发布时间】:2011-11-23 14:22:21
【问题描述】:
我翻译了包含日期的字符串。
{% trans with {'%date%': lastAcceptedDate } from "translations" %}createdBefore%date%notAccepted{% endtrans %}
现在我想格式化日期。可能是按日期功能。类似于 PHP 中的以下内容
__( 'createdBefore%date%notAccepted',
array(
'%date%' => (new DateTime($lastAcceptedDate))->format('d.m. Y')
)
);
这绝对不是工作或最佳代码。这只是对我想要实现的目标的另一种解释。
我发现我可以用像这样的普通字符串在树枝上做到这一点
{{ lastAcceptedDate | date("d.m. Y") }}
但我无法在 twig 的翻译标签中找到如何做到这一点。
【问题讨论】:
标签: formatting symfony translation twig