Daniele Dolci
Daniele Dolci

Reputation: 884

Symfony translations use always default EN

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

Answers (1)

martin
martin

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

Related Questions