我使用symfony 4.0中的翻译组件和YAML加载器。根据{{3}}我能够将我的消息嵌入这样的键中:
msg:
foo: baz
bar: qux
当我使用以下方法检索值时,哪种方法正常。
$translator->trans(
'msg.foo'
);
我所挣扎的是在混合中加入多元化 - 例如:
$translator->transChoice(
'msg.singular|msg.plural',
2
);
这在它自己的输出中msg.singular
或者在这种情况下msg.plural
按预期输出,并且当我定义它们时它会消息:
msg.singular|msg.plural: There is one Apple|There are %count% Apples
它赢得不接受的是以下任何一项:
msg:
singular: There is one Apple
plural: There are %count% Apples
# or
msg:
singular|plural: There is one Apple|There are %count% Apples
这是有道理的,因为它会变得扁平化:
msg.singular: There is one Apple
msg.plural: There are %count% Apples
# or
msg.singular|plural: There is one Apple|There are %count% Apples
我的问题是:我如何使用symfony提供的复数功能,同时利用嵌套密钥来翻译我的翻译数据?