我将 symfony 4.0 中的翻译组件与 YAML 加载器一起使用。根据文档,我可以将我的消息嵌套在这样的键中:
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 提供的复数功能,同时为我的翻译数据使用嵌套键?