symfony - Pass variables to Twig Translator -
in messages.en.yml:
variable_name: welcome %site_name% - %other_info%
in twig
{{ 'variable_name'|trans( -here- ) }}
it's -here- part i'm struggling know how pass data in. must way (above example).
maybe i'm misunderstanding question if understand correctly, need give array first parameter of trans filter.
{{ 'variable_name'|trans({'%site_name%': 'my website'}) }}
and of course, values can variables if don't put them between quotes :
{{ 'variable_name'|trans({'%site_name%': 'my website', '%other_info%': page_name}) }}
Comments
Post a Comment