Search code examples
phpsymfonysonata-adminsonata

Sonata Admin local translation strategy for a list column


Is there an easy way to adjust a local translation strategy for a field added to a listMapper? So the column header will be shown exactly how it's been written in a label attribute without any gaps.

BusinessUserAdmin.php

protected function configureListFields(ListMapper $listMapper)
{
    $listMapper
        ->add('company', null, [
            'label' => 'Company'
        ])
}

This is how it looks like now:

    'label' => 'Company'       'label' => 'COmpany'       'label' => 'COMPANY'

   Company     COmpany       COMPANY


Solution

  • When you register your admin class as service and tag it with : sonata.admin, there is additional option label_translator_strategy="sonata.admin.label.strategy.underscore”

    You can find more info here :

    https://sonata-project.org/bundles/admin/master/doc/reference/translation.html