简体   繁体   中英

Symfony 2.6 - Translation does not work

I've installed fresh symfony2, and I tried to translate text, but in debug:translation, ids are duplicated, and twig output shows me Id, not Message Preview text. What is wrong?

app/console debug:translation output:

+----------+-----------+----------------------+
| State(s) | Id        | Message Preview (en) |
+----------+-----------+----------------------+
| x        | base.test | base.test            |
| o        | base.test | This is test         |
+----------+-----------+----------------------+

twig input:

{% trans %}base.test{% endtrans %}

twig output:

base.test

base.en.yml:

base.test: This is test

You need to define the translation domain.

{% trans from "base" %}base.test{% endtrans %}

And configure your config.yml :

framework
    translator: { fallback: en }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM