Symfony translations not working

Michael picture Michael · Oct 2, 2013 · Viewed 41.7k times · Source

I have done the following checklist:

  1. created translation file respecting format domain.lang.loader
  2. cleared cache
  3. checked that language catalogue is created in cache folder

Though in my twig template file,

{{ 'message'|trans }}

never translates.

Where can I look next in order to make translations work?

Is there any chance that Doctrine Translatable Extension that I am using generates some kind of conflicts?

Answer

Ankit Khedekar picture Ankit Khedekar · Oct 3, 2013

Have you enabled the Translator service in your config file?

framework:
    translator: { fallbacks: en }

The language catalogue is created in your cache folder irrespective of whether your translator is enabled or not.

Did you try translating in your controller?

$trans = $this->get('translator')->trans('message');