Peter Artoung
Peter Artoung

Reputation: 224

Symfony 3 - Translation doesn't work

(and sorry for my poor english)

I'm setting up translation on my project but impossible.

I would like to be able to translate my site in French, but it remains in English.

For the moment I only want to translate strings of characters in twig, without variables.

My parameters.yml :

parameters:
    locale: fr

And my config.yml :

imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }

framework:
    #esi:             ~
    translator: { fallback: %locale% }
    secret:          "%secret%"

If I do : dump($request->getLocale());die(); in my controller, I got : "fr"

So my config is good.

And in my twig :

<label>{{ 'cancel'|trans }}</label>

But it still shows me "cancel".

Also, if I fly over the twig code, my editor tells me: "Missing tranlation key".

I just want for the moment translate a string, without varialbes.

Does someone have an idea ? Thank you in advance

Upvotes: 1

Views: 854

Answers (1)

KhorneHoly
KhorneHoly

Reputation: 4766

I think that you're missing your translation files, where you define the translations.

You need to define them into specific locations, e.g. /app/Resources/translations/messages.fr.yml

For more information check the documentation.

Upvotes: 1

Related Questions