Reputation: 1460
I have a Sylius instance with translations file configured and properly working
Right now just using a snippet like this in my twig
:
{{ 'project.sylius.frontend.header.label'|trans }}
It retrieves the proper string from the yaml
translation file:
project.sylius.frontend.header.title: Welcome here
What I want to know is, if there is the chance to store the strings with interpolation marks straight in the yaml
,
something like this:
project.sylius.frontend.cart_number: you are going to buy %n candies
project.sylius.frontend.delivery: delivery will be between the %whatever and %whatever
And how to pass the variable in the the twig
file
Upvotes: 2
Views: 1484
Reputation: 39470
You can pass variable to the trans filter as first argument as array, as Example:
yaml:
project.sylius.frontend.cart_number: you are going to buy %number% candies
Twig:
{{ 'project.sylius.frontend.cart_number '|trans({'%number%': '4'}) }}
Take a look at the pluralization features.
Hope this help
Upvotes: 2