I'm trying to find a way to translate the labels and titles. According to he ZF2 Manual all I have to do this:
The navigation helpers support translation of page labels and titles. You can set a translator of type Zend\I18n\Translator in the helper using $helper->setTranslator($translator).
So my navigation looks like this in config file
return array(
'navigation' => array(
'default' => array(
array(
'label' => 'Home',
'route' => 'home',
),
array(
'label' => 'Users',
'route' => 'tar-users',
),
),
),
);
This is in global.php
return array(
'service_manager' => array(
'factories' => array(
'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
),
),
//...
);
And in my layout I have:
<?php echo $this->navigation('navigation')
->setTranslator($this->plugin('translate')->getTranslator())
->menu()
->setUlClass('nav navbar-nav')
->setMaxDepth(0)
?>
The navigation is working but is not translating. I'm sure I missed something or I did something wrong. I'd like to know what. I don't what you to write the code just some tips.
Thank you.