Reputation: 884
I have italian language set on my browser, but symfony localization give me only english translations. How can I get italian strings if i access the page with italian browser?
Now i see "pluto" in EN Browser and in IT Browser.
Config.yml:
parameters:
locale: en
framework:
translator: { fallbacks: ['%locale%'] }
messages.en.yml:
Pippo: pluto
messages.it.yml:
Pippo: paperino
index.html.twig:
{% block body %}
<div class="container">
<div class="row">
<div class="col-sm-12">
{% trans %}
Pippo
{% endtrans %}
</div>
</div>
</div>
{% endblock %}
Thanks
Upvotes: 1
Views: 763
Reputation: 96969
If you want to set current locale from headers you need to a make an event listener for kernel.request
event that sets $request->setLocale(...)
.
See similar questions:
Upvotes: 5