문제

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 ?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top