2

At the end of http://symfony.com/doc/current/book/translation.html#twig-templates I read about

{% trans_default_domain "app" %}

to set a translation domain for a whole template. But for me it does not work. Calling

app/console translation:extract de --dir=src/ --output-dir=app/Resources/translations --output-format=xliff --keep

Just puts all messages in the messages.de.xliff file.

But if I set the domain manually for a given label like

{{ label.name|trans({}, 'app') }}

And execute the same extract command as above, then I get a new file app.de.xliff

Is there anything more to do when using trans_default_domain?

j0k
  • 22,600
  • 28
  • 79
  • 90
schingeldi
  • 870
  • 2
  • 14
  • 26

2 Answers2

5

It seems that you forget simple quot, try this instead

{{ 'label.name'|trans({}, 'app') }}

or this

{{ 'label.name'|trans }}
j0k
  • 22,600
  • 28
  • 79
  • 90
aeh
  • 51
  • 2
3
{% trans_default_domain "app" %}

That's working fine, but you should clear your cache if the translation files didn't exist before to get it working.

Pi Wi
  • 1,076
  • 1
  • 11
  • 20