I'd like to translate a part of my twig template which is not in my trans_default_domain
For exemple:
{% trans_default_domain 'FOSUserBundle' %}
{{ 'test.trans'|trans({}, 'ProjectMainBundle') }}
So test.trans
is translated in ProjectMainBundle but I always have test.trans
in my text.
Edit:
test.trans
is in src/Project/MainBundle/Resources/translations/messages.en
It works everywhere but it doesn't work when I am trying to get my trans with a trans_default_domain
You are storing the translation in a file called
messages.en.yml
which means according to the naming conventions for translations these translations have the domainmessages
and notProjectMainBundle
.Therefore the translator doesn't find a translation if you're trying to use the domain
ProjectMainBundle
and returns the string itself.Your translations should be stored in
@AcmeYourBundle/Resources/translations/<domain>.<locale>.yml
( or php, xliff, ... ).Remember to clear your cache after renaming.