KnpLabs / KnpTimeBundle

Provides helpers for time manipulation
http://knplabs.com
MIT License
602 stars 105 forks source link

fix: pluralization not being used for duration translations #183

Closed kbond closed 1 year ago

kbond commented 1 year ago

Pluralization is not being triggered for the new duration translations:

{{ 1|duration }} {# 1 second|%count% seconds #}
{{ 2|duration }} {# 2 seconds #}

I can't immediately see the issue...

weaverryan commented 1 year ago

You mean it's literally outputting 1 second|%count% seconds?

kbond commented 1 year ago

You mean it's literally outputting 1 second|%count% seconds?

Yes

weaverryan commented 1 year ago

What does $seconds look like by the time it gets here? https://github.com/KnpLabs/KnpTimeBundle/blob/main/src/DateTimeFormatter.php#L56

kbond commented 1 year ago

1.0, 2.0, etc

kbond commented 1 year ago

Found the problem, I'm not passing %count% to https://github.com/KnpLabs/KnpTimeBundle/blob/3fe79604a94c0f77fc28613e9fc45b6ce665ecf6/src/DateTimeFormatter.php#L76

weaverryan commented 1 year ago

Thanks Kevin!