I´m working in a Zend Framework 2 project and I´m using the View Helper (Breadcrumbs) to inject this navigation component into my views.
To render my Breadcrumbs the following code is used:
<?php echo $this->navigation('Navigation')
->breadcrumbs()
->setLinkLast(false) // link last page
->setMaxDepth(7) // stop at level 7
->setMinDepth(0) // start at level 0
->setSeparator(' »' . PHP_EOL); // separator with newline
?>
I´ve been translating most of the project´s content with the following code
<?php echo $this->translate("Text to translate here", $textDomain); ?>
So applying the same logic to the existing code:
<?php echo $this->translate($this->navigation('Navigation')
->breadcrumbs()
->setLinkLast(false) // link last page
->setMaxDepth(7) // stop at level 7
->setMinDepth(0) // start at level 0
->setSeparator(' »' . PHP_EOL), "navigation"); // separator with newline
?>
Is this the most efficient and/or correct way to translate the breadcrumbs? The text domain here set as "navigation" is where this translation lives. Without being set it defaults to the value "default".
you cannot really do it like this, you're passing html to the translator. simply use these methods on the viewhelper:
$navHelper->setTranslator($yourTranslator);
$navHelper->setTranslatorTextDomain('de_DE');
$navHelper->setTranslatorEnabled(true); // (default)
$navHelper->setInjectTranslator(true); // to pass the translator down to menu/breadcrumbs etc. (default)