Reputation: 46168
I've extended SonataUserBundle and I'm trying to put french translations in it.
Here is my admin service definition:
sonata.admin.user:
class: Application\Sonata\UserBundle\Admin\Entity\UserAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: user, label: users }
arguments:
- null
- Application\Sonata\UserBundle\Entity\User
- SonataAdminBundle:CRUD
calls:
- [setTranslationDomain, [SonataUserBundle]]
- [setUserManager, [@fos_user.user_manager]]
- [setSecurityContext, [@security.context]]
As you can see, the translation domain is set to SonataUserBundle
.
I have set some labels in src/Application/Sonata/UserBundle/Resources/translations/SonataUserBundle.fr.yml
#...
list:
label_firstname: Prénom
label_username: Nom d'utilisateur
#...
But they are not taken into account (cache cleared)
However, if I remove this file, it insults me with
The file ".../src/Application/Sonata/UserBundle/Resources/translations/SonataUserBundle.fr.yml" must contain a YAML array.
Modifying the translation domain has no effect at all.
What am I doing wrong ?
Upvotes: 2
Views: 3461
Reputation: 2057
You have add label_translator_strategy: sonata.admin.label.strategy.underscore in the service definition:
sonata.admin.user:
class: Application\Sonata\UserBundle\Admin\TestAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: users, label: users, label_translator_strategy: sonata.admin.label.strategy.underscore }
arguments:
- null
- Application\Sonata\UserBundle\Entity\User
- SonataAdminBundle:CRUD
calls:
- [setTranslationDomain, [SonataUserBundle]]
- [setUserManager, [@fos_user.user_manager]]
- [setSecurityContext, [@security.context]]
I have tested in a new project, and it works fine.
Upvotes: 4