2

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 ?

Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
  • SonataUserBundle is already translated. Did you change the locale in your parameters en config files ? – Picoss Jul 05 '13 at 09:06
  • Locale is already set to french, other admins work fine. In fact there is only the UserAdmin part that is doing it (the wrapping SonataAdmin is in french). I suspect my admin service to miss something. – Pierre de LESPINAY Jul 05 '13 at 09:21

1 Answers1

4

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.

Picoss
  • 2,047
  • 13
  • 14