Home > OS >  Concat translated key on twing using symfony 3.4
Concat translated key on twing using symfony 3.4

Time:09-22

I'm trying to gererate the translation key that has to be translated and show at the template but is not working

<h2 class="text-withe">{{  'cover.title.'~product.id | trans | raw }}</h2>

this way it works, but I think it should work without create a variable

{% set title_key = 'cover.title.'~product.id %}
<h2 class="text-white">{{ title_key | trans | raw }}</h2>

CodePudding user response:

As I know it's expected behavior

you should try something like this:

{{ ('cover.title.'~product.id) | trans | raw }}

Without () it will translate product.id and concatenate with cover.title.

CodePudding user response:

when you put | it just look for the value before | all you have to do is use parentheses you show that you one translate all of that like this:

('cover.title.'~product.id)| trans | raw
  • Related