Advanced customization of translations in Symfony2

后端 未结 3 1757
無奈伤痛
無奈伤痛 2020-12-10 16:35

I have a Symfony2 project and I am using Translation component for translating text. I have all translations in yml file like so

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-10 17:09

    As of Symfony 3, Venu's answer no longer works completely, as the translator.class parameter is no longer used.

    To load your custom translator class, you now need to create a compiler pass.

    getDefinition('translator.default')->setClass(Translator::class);
        }
    }
    

    And this compiler pass needs to be added to the container.

    addCompilerPass(new TranslatorOverridePass());
        }
    }
    

提交回复
热议问题