Sonata Admin翻译不翻译翻译数组

Sonata Admin translation does not translate translation array

我在 Sonata Admin 中有一个翻译数组,如下所示:

messages.en.yml

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

当我尝试像这样访问它时

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

或者像这样

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

它们不起作用,我得到了密钥字符串作为响应。

但是如果我这样使用它:

messages.en.yml

admin_form_label_identifier_identificationTitle: some text here

the view

{{ 'admin_form_label_identifier_identificationTitle'|trans }}

有效。

显然我不想使用这种格式,但使用了很好的数组格式选项。 这甚至可以在 Sonata Admin 中实现吗?

我想你的项目中某处有翻译 admin.form.label.

当您将相同的键定义为值和数组时,只有一个翻译工作。例如:

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