1

I'm trying to get a nice formatted string for a datetime interval.

Basically I have %count% as -2 for "two days ago", 4 for "in 4 days", 0 for "today", 1 for "tomorrow" and so on.

My translation string looks like this:

dateinterval: '{0} today|{1} tomorrow|{1} the day after tomorrow |{-1} yesterday|[2,Inf[ In %count% days|]-Inf,-2]%count% days ago'

And that works fine, except that I have a negative sign in the interval ]-Inf,-2]:

-3 days ago -43 days ago

Is there any way to make %count% an absolute number within the translation string?

Thanks!

Matthias
  • 11
  • 1
  • 1
    Did you check with an if and Twig abs filter https://twig.symfony.com/doc/2.x/filters/abs.html ? Also could you add a part of your template where translation is called – qdequippe Jun 28 '21 at 09:05

0 Answers0