sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

KnpMenu Translation using setExtra method not working in configureTabMenu #2946

Closed webdevilopers closed 8 years ago

webdevilopers commented 9 years ago

Regarding KnpMenu Translation http://symfony.com/doc/current/bundles/KnpMenuBundle/i18n.html I tried this code:

    protected function configureTabMenu(MenuItemInterface $menu, $action, AdminInterface $childAdmin = null)
    {
        if (!$childAdmin && !in_array($action, array('edit', 'show'))) { return; }

        $admin = $this->isChild() ? $this->getParent() : $this;
        $id = $admin->getRequest()->get('id');

        $menu->addChild('List Products', array('uri' => $admin->generateUrl('sonata.admin.electrical_equipment.list', array('id' => $id))))
             ->setExtra('translation_domain', 'InternalBundle');

        $menu->addChild($this->trans('List Products'), array('uri' => $admin->generateUrl('sonata.admin.electrical_equipment.list', array('id' => $id))));
    }

Unfortunately the first label is not being translated using setExtra. The translation file is fine since it works with $this->trans().

Is this an issue with a template outputting the tab menu or an KnpMenu issue?

greg0ire commented 8 years ago

Fixed by #3986 I think.