According to knp, this should be how you can easily add translations to your menu. It ain't working for me. My menu class:
public function createMainMenuLeft(array $options)
{
$menuLeft = $this->factory->createItem('root', array('childrenAttributes' => array('class' => 'left')));
$menuLeft->addChild('test', array('route' => 'test_route'))
->setExtra('translation_domain', 'AppBundle');
return $menuLeft;
}
In AppBundle/Resources/translations/messages.en.yml I have
test: nothing
However, my menu still has the label 'test' not the value from the translations file. Am I missing something here?
My locale is set in config.yml
to en
.
After some research I found the way to do it inside the documentation from the bundle, not the one from symfony. The template hast to be overwritten. Source