php - Translation filter inside a twig {% raw %} block -
i have html template containing handlebarsjs code include in page render product popups. problem templates bit complex , i'd need translate labels on them too, there way notify exception twig parser? that, though code inside raw
block rendered anyway? if use translation tag doesn't work {{ 'translations.project.template.price'|trans }}
eg: index.html.twig:
{{ include('webbundle:frontend:partials/templates/product-template.html.twig') }}
product-template.html.twig:
{% trans_default_domain "home" %} {% raw %} {{#if islovepromo}} <div class="product-infotag promo"> promozione <!-- here text i'd translate --> </div> {{/if}} {% endraw %}
at moment i'm working aroun passing translations object rendered handlebars have this:
index.html.twig:
data.translations = { promo: "{{ 'translations.project.template.promotion'|trans }}" }
template.render(data); product-template.html.twig:
... <div class="product-infotag promo"> {{ promo }} </div> ...
this method works it's overkill, have templates in have pass more 12 strings , looks not efficient me way.
is there way of addressing directly in twig?
Comments
Post a Comment