Is it possible to check if given variable is string in Twig ?
Expected solution:
messages.en.yml:
hello: stranger: Hello stranger ! known: Hello %name% ! Twig template:
{% set title='hello.stranger' %} {% set title=['hello.known',{'%name%' : 'hsz'}] %} {% if title is string %} {{ title|trans }} {% else %} {{ title[0]|trans(title[1]) }} {% endif %} Is it possible to do it this way ? Or maybe you have better solution ?
iterabletest? twig.sensiolabs.org/doc/tests/iterable.html