Php 符号翻译中的转换选择
我的语言文件中有以下PHP翻译字符串:Php 符号翻译中的转换选择,php,symfony,Php,Symfony,我的语言文件中有以下PHP翻译字符串: 'string.month' => '1 month', 'string.months' => '%month% months', 我在我的小树枝文件中使用这个: {% transchoice data.frequencyInMonths() with {'%month%': data.frequencyInMonths()} from "strin
'string.month' => '1 month',
'string.months' => '%month% months',
我在我的小树枝文件中使用这个:
{% transchoice data.frequencyInMonths() with {'%month%': data.frequencyInMonths()} from "strings" %}
{0,[2,Inf]} string.months|trans({'%month%' : data.frequencyInMonths()})|{1} string.month|raw
{% endtranschoice %}
显然,这是行不通的。我只想获得string.month
已使用的数据.frequencyInMonths()==1
,以及string.months
,并为其他所有内容(即0和2到无穷大)注入数字
我该怎么做
谢谢解决问题的最简单方法是: 翻译文件代码: 细枝文件代码: 复杂方式,如果您需要特殊的0个月消息(无月): 翻译文件代码: 细枝文件代码与上次相同: 备注: 翻译的第一个值中没有use'字符,因此您可以随时使用:
string.month: 'something about month'
如果您的翻译(第二个值)是简单字符串。因此,如果“something about month”字符串不包含任何特殊字符,则可以使用:
string.month: something about month
'string.months': '{0} none months|{1} one month|]1,Inf] %count% months'
{% set count = data.frequencyInMonths() %}
{{ "string.months"|transchoice(count) }}
string.month: 'something about month'
string.month: something about month