Reputation: 174
I'm using Symfony 6 and don't understand how I should enable translation for dependency messages. For example: I just installed SymfonyCasts/verify-email-bundle which provides translations in its directory (src/Resources/translations)
To enable them, I have:
composer require symfony/translation
default_locale
to fr
in my config/packages/translation.yamlbin/console cache:clear
rm -rf var/log/translations
Then, all messages that should be handled by the provided translations are still in English.
I have also tried to force translation by calling myself the $translator->trans()
method on the string returned by the bundle. The profiler then says the translation is missing and fallbacks to en
as configured.
I have tried to copy the bundle VerifyEmailBundle.fr.xlf file into my own /translations directory but got the same error. bin/console debug:translation fr
shows me the needed translations but all are marked as unused
.
I encounter the same issue with multiple bundles and don't see anything in the offical documentation about this.
What am I missing?
Upvotes: 2
Views: 740
Reputation: 51
To set default language you must set #config/packages/translation.yaml like this:
framework:
default_locale: fr
translator:
default_path: '%kernel.project_dir%/translations'
fallbacks:
- fr
and you can add translations at #translations/messages.fr.yml
Hello: 'Bonjour'
This friendly message is coming from: 'Ce message amical vient de'
Welcome to my new App: 'Bienvenue sur ma nouvelle application'
user:
profile:
admin: 'administrateur'
Upvotes: 1