-2

I am using Symfony EasyAdmin 4 and couldn't figure out how to change the main menu's entities' labels. They default to their entities' name.

This seems easily achievable with EasyAdmin 2.x, as the old docs show. But none of the files mentioned there (translations/messages.xx.yaml,config/packages/easy_admin.yaml) is still in use in EasyAdmin 4.x.

So, how to translate the Main Menu Labels in EasyAdmin?

Omar Trkzi
  • 130
  • 1
  • 2
  • 13

1 Answers1

-2

We don't need any of those files anymore in EasyAdmin 4:

First: change the default_locale

In the: config/packages/translation.yaml file, set:

framework:
        default_locale: xx

where xx is the target language (e.g es for spanish, fr for french, de for german, etc)

Second: Implement config crud methods

Implement setEntityLabelInSingular and setEntityLabelInPlural methods inside the configureCrud function inside the concerned crud controller:

class YourCrudController extends AbstractCrudController
{     
...   
    public function configureCrud(Crud $crud): Crud
         {
             return $crud
                 ->setEntityLabelInSingular('Your own label')
                 ->setEntityLabelInPlural('Your own labels')
                 ...
                 ;
          }
...
}

Don't forget the : use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;


More here: Symfony: The Fast Track

Omar Trkzi
  • 130
  • 1
  • 2
  • 13