I'm using Symfony 2.3 with Sonata Admin Bundle. I know that I can translate a label in this way:
->add('shortDescription', null, array('label'=>'shortDescriptionTranslated'))
But this is possible only with "configureFormFields" method, not for dataGrid and listFields.
Can you provide me a complete example for translating labels in global way? I have looked here (Labels in Sonata Admin Bundle) but I have no idea what to write in the xliff file.
Thanks!
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.
来源:https://stackoverflow.com/questions/17685256/how-to-translate-labels-in-sonata-admin-bundle