0

I've got a case where I need to translate messages with pluralization and also format the number differently.

Example messages I wish to get in the translation are:

No views
1 view
100 views
1 234 567 views

Till now I used:

{{ variable.count|number_format(0, '.', ' ') }} views

I've tried:

{{ 'number_of_views'|trans({count: variable.count}) }}

but then I get:

1,234,567 views

instead of

1 234 567 views

How I can use translation with number_format for the same keyword?

nass
  • 382
  • 1
  • 6
  • 19
  • 1
    Result of number_format function is actually string. For pluralization you need number (integer or float). So the answer is "no". But you should take a look at https://symfony.com/doc/master/translation/message_format.html#numbers – ffx14 May 14 '20 at 19:24
  • Does this answer your question? [How to translate with pluralization in Twig?](https://stackoverflow.com/questions/7384745/how-to-translate-with-pluralization-in-twig) – Nico Haase May 15 '20 at 09:08

0 Answers0