simPod
simPod

Reputation: 13466

Symfony pluralization ignoring floats

I'm using Symfony Translations ported into my framework. I found this in docs:

'{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.

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

My problem is that I need to use different plural for 1.5 than I'm using for 1. How can I do that? When I pass 1.5 as a count parameter, it gets 1 plural assigned.

I thought specifying interval as ]1,something] would work, but it's basically the same as [2,something] according to docs (In that case I don't see a point in using ]1 anyway). How can I cover 1.5 plural?

Upvotes: 1

Views: 178

Answers (1)

MarcoReni
MarcoReni

Reputation: 478

According to Symfony reference, 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), accept an int value, so I think what you're trying to achieve is not possible.

You may, however, override the Translator service and implement your logic. See here for details.

Upvotes: 1

Related Questions