How to translate labels in Sonata Admin Bundle

ぃ、小莉子 提交于 2019-12-06 05:12:27

Did you review the translation documentation from the Sonata Project website: http://www.sonata-project.org/bundles/admin/master/doc/reference/translation.html ?

You can set a global catalogue per Admin, the default one will be 'messages'. Depends on the translation strategy the source key will be different, one you get the key you can translate the related label as any other translation from the Symfony Framework by using xliff or yaml files.

It works in the same way:

protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
    $datagridMapper
        ->add('id', null, array('label' => 'ID'))
        ->add('username', null, array('label' => 'Логин'))
    ;
}

protected function configureListFields(ListMapper $listMapper)
{
    $listMapper
        ->addIdentifier('id', null, array('label' => 'ID'))
        ->addIdentifier('username', null, array('label' => 'Логин'))
    ;
}

You can see the result here: http://joxi.ru/V57lUdg5CbCqHxR9UwY

Overriding the xliff file gives you translating of the standart UI elements, not entity labels.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!