Skip to content
Advertisement

Is there way to pass Symfony variables to translation without keys

we are now using custom translations for our project in PHP and I want to migrate them to Symfony ones. Everything looks great, but my only concern is that variable placeholders needs key to bind successfully, can I somehow change the code to accept translation variables in sequence (without keys)?

Let me show an example:
Our code now:

JavaScript

But this is how Symfony wants it:

JavaScript

This is what I want:

JavaScript

Is this somehow possible? I didn’t find it anywhere in the documentation and Google didn’t help either.

Advertisement

Answer

I have solved it by myself this is the code (in case anyone needs it):

Basically, it gets all %variables% and sets them as array keys with corresponding array values from $parameters variable.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement