How to translate labels in Sonata Admin Bundle

Diego picture Diego · Jul 16, 2013 · Viewed 9.5k times · Source

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!

Answer

rande picture rande · Jul 25, 2013

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.