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 domain messages
and not ProjectMainBundle
.
Therefore the translator doesn't find a translation if you're trying to use the domain ProjectMainBundle
and returns the string itself.
Each message file must be named according to the following path: domain.locale.loader
Your translations should be stored in @AcmeYourBundle/Resources/translations/<domain>.<locale>.yml
( or php, xliff, ... ).
Remember to clear your cache after renaming.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With