Symfony 多元化忽略浮点数
Symfony pluralization ignoring floats
我正在使用移植到我的框架中的 Symfony 翻译。我在文档中找到了这个:
'{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
需要使用与 1
不同的复数形式。我怎样才能做到这一点?当我将 1.5
作为计数参数传递时,它得到 1
复数分配。
我认为将间隔指定为 ]1,something]
会起作用,但根据文档,它与 [2,something]
基本相同(在那种情况下,我看不出使用 ]1
有什么意义反正)。如何覆盖 1.5
复数?
根据 Symfony 参考,Interval
(http://api.symfony.com/2.7/Symfony/Component/Translation/Interval.html ) and TranslatorInterface (http://api.symfony.com/2.7/Symfony/Component/Translation/TranslatorInterface.html),接受一个 int
值,所以我认为你想要实现的目标是不可能的。
但是,您可以覆盖翻译服务并实现您的逻辑。有关详细信息,请参阅 here。
我正在使用移植到我的框架中的 Symfony 翻译。我在文档中找到了这个:
'{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
需要使用与 1
不同的复数形式。我怎样才能做到这一点?当我将 1.5
作为计数参数传递时,它得到 1
复数分配。
我认为将间隔指定为 ]1,something]
会起作用,但根据文档,它与 [2,something]
基本相同(在那种情况下,我看不出使用 ]1
有什么意义反正)。如何覆盖 1.5
复数?
根据 Symfony 参考,Interval
(http://api.symfony.com/2.7/Symfony/Component/Translation/Interval.html ) and TranslatorInterface (http://api.symfony.com/2.7/Symfony/Component/Translation/TranslatorInterface.html),接受一个 int
值,所以我认为你想要实现的目标是不可能的。
但是,您可以覆盖翻译服务并实现您的逻辑。有关详细信息,请参阅 here。