Search code examples
phpsymfonysonata-adminsymfony-sonatasonata

Sonata Admin translation does not translate translation array


I am having a translation array in Sonata Admin that looks like this:

messages.en.yml

admin:
    form:
        label:
            identifier:
                identificationTitle: Some text here
                otherKey: blabla

when I am trying to access it like this

{{ 'admin.form.label.identifier.identificationTitle'|trans }}

or like this

{{ 'admin.form.label.identifier.identificationTitle'|trans({}, 'MyBundle') }}

they don't work and I get as a response the key string.

But if I use it like this:

messages.en.yml

admin_form_label_identifier_identificationTitle: some text here

the view

{{ 'admin_form_label_identifier_identificationTitle'|trans }}

it works.

Obviously I don't want to have this format but use the nice array formatted option. Is this even possible in Sonata Admin?


Solution

  • I suposse that somewhere in your project there is translation for admin.form.label.

    When you define the same key as value and also as array, only one of translation work. Eg:

     admin: translation for admin
     admin:
        form:  translation for admin.form