Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 符号翻译中的转换选择_Php_Symfony - Fatal编程技术网

Php 符号翻译中的转换选择

Php 符号翻译中的转换选择,php,symfony,Php,Symfony,我的语言文件中有以下PHP翻译字符串: 'string.month' => '1 month', 'string.months' => '%month% months', 我在我的小树枝文件中使用这个: {% transchoice data.frequencyInMonths() with {'%month%': data.frequencyInMonths()} from "strin

我的语言文件中有以下PHP翻译字符串:

'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