1

我正在使用移植到我的框架中的 Symfony Translations。我在文档中找到了这个:

'{0} There are no apples|{1} There is one apple|]1,19] There are %count% apples|[20,Inf[ There are many apples'

The above string specifies four different intervals: exactly 0, exactly 1, 2-19, and 20 and higher.

来源:http ://symfony.com/doc/current/components/translation/usage.html#explicit-interval-pluralization

1.5我的问题是我需要使用与 for 不同的复数形式1。我怎样才能做到这一点?1.5当我作为计数参数传递时,它会被1分配复数。

我认为指定间隔是]1,something]可行的,但它与文档中的基本相同[2,something](在那种情况下,我无论如何都看不到使用的意义]1)。如何覆盖1.5复数?

4

1 回答 1

1

根据 Symfony 参考,Intervalhttp://api.symfony.com/2.7/Symfony/Component/Translation/Interval.html)和 TranslatorInterface(http://api.symfony.com/2.7/Symfony/Component/Translation/TranslatorInterface .html),接受一个int值,所以我认为你想要实现的目标是不可能的。

但是,您可以覆盖 Translator 服务并实现您的逻辑。有关详细信息,请参见此处

于 2015-08-29T23:14:03.073 回答