Level 122
How could you possibly add something that is calculated in the client to the server output?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi!,
I've got this in a .blade file:
<p class="text-grey-darker mt-1"><i>@{{ add.locations.length }} {{ ngettext('location', 'locations', 2) }}</i></p>
I want to pluralize location. But how do I add the javascript length to the ngettext php method?
This is obviously not working:
{{ ngettext('location', 'locations', @{{ add.locations.length }} ) }}
Thanks!
If locations (the variable) is coming from the server then you could check the length there and pass through the correct word.
Else just use a javascript ternary inline or a vue computed property?
Please or to participate in this conversation.