I've created a custom offcanvas (as a plugin) and I've extended @Storefront/storefront/utilities/offcanvas.html.twig
. In the Twig file I placed among others a snippet like this {{ 'enquiry.amount.subtitle'|trans|sw_sanitize }}
.
In the administration I filled in the translation for the snippet in EN, DE, ES and NL. But for some reason I'm always seeing the EN translation, no matter what language I've switched too.
I've used snippets before in my custom theme and then the translations are working just fine, but in the custom offcanvas it isn't working.
Any idea how this can happen?
Edit
When I dump app.request.get('_locale')
in a page I'm getting nl-NL
. But when I dump it in the offcanvas I'm getting en-GB
I wasn't able to reproduce that on the current release 6.5.4.0
.
{% sw_extends '@Storefront/storefront/utilities/offcanvas.html.twig' %}
{% block utilities_offcanvas_meta %}
{{ "foo.bar"|trans|sw_sanitize }}
{% endblock %}
With foo.bar
having the value foo
for locale de-DE
and bar
for en-GB
, it did yield the expected result switching from the domain of one locale to the other.
Are you sure you're requesting the content of the offcanvas with the correct domain of the locale? Try and dump {{ app.request.locale }}
somewhere in your template, to see the locale associated with the request.
For testing purposes you can also explicitly provide a locale for the translation. If your translations are set up correctly, this should definitively work.
{{ "foo.bar"|trans([], null, "en-GB") }}
{{ "foo.bar"|trans([], null, "de-DE") }}