Issue Type: Improvement Created: 2011-01-14T04:52:36.000+0000 Last Updated: 2013-02-10T16:18:46.000+0000 Status: Open Fix version(s): Reporter: Tomek Pęszor (admirau) Assignee: Frank Brückner (frosch) Tags: - Zend_Navigation
Related issues: Attachments: - 0001-Add-useTranslator-support-for-Zend_Navigation-contai.patch
Zend_Navigation always translates labels and titles for the container.
There is an option in the view helper to disable the translation for the whole container, but there is no option to disable this translation for specific pages.
Example use case:
<pre class="highlight"> $page = new Zend_Navigation_Page_Mvc( array( 'label' => $blogPost->alreadyTranslatedTitleFromDb // ... ) ); $page2 = new Zend_Navigation_Page_Mvc( array( 'title' => 'Edit: ' . $blogPost->alreadyTranslatedTitleFromDb // ... ) ); $container->addPage($page); $container->addPage($page2);
Now, when I use:
<pre class="highlight"> $page->getLabel();
<pre class="highlight"> $page2->getTitle();
the label is translated twice. The same for breadcrumbs, sitemaps etc.
Translation logs are filled with ~random messages.
Option to disable the translation is needed:
<pre class="highlight"> $page = new Zend_Navigation_Page_Mvc( array( 'label' => $blogPost->alreadyTranslatedTitleFromDb 'disableTranslation' => true // ... ) );
Posted by Kai Uwe (kaiuwe) on 2011-01-14T05:33:11.000+0000
This is not a bug, because the Zend_Navigation - view helpers translate the label and title only once! I think this is more of a suggestion for an improvement. Please change the type of these issue and remove it as an affected component Zend_Translate.
Can you write a few tests and a patch? That would be very useful for quick editing. Thanks.
Posted by Tomek Pęszor (admirau) on 2011-01-15T03:08:28.000+0000
Changed priority to major, because the patch with unit tests is available and can be easily fixed.
Posted by Tomek Pęszor (admirau) on 2011-01-15T03:17:48.000+0000
I wrote a fix for this issue, including unit tests. The fix is backwards compatible.
Here is link to the patch and modified files: http://taat.pl/useTranslator_Zend_Navigation_Conta… (how can I upload it here? Could someone do this?)
This basically adds useTranslator property with getter and setter, and some conditions in view helpers handling the new option.
The patch contains new methods for the unit tests and the modifications to the library itself.
List of modified files.
Modified: library/Zend/Navigation/Container.php Modified: library/Zend/Navigation/Page.php Modified: library/Zend/View/Helper/Navigation/Breadcrumbs.php Modified: library/Zend/View/Helper/Navigation/HelperAbstract.php Modified: library/Zend/View/Helper/Navigation/Menu.php
Modified: tests/Zend/Navigation/ContainerTest.php Modified: tests/Zend/Navigation/PageTest.php Modified: tests/Zend/View/Helper/Navigation/BreadcrumbsTest.php Modified: tests/Zend/View/Helper/Navigation/MenuTest.php Modified: tests/Zend/View/Helper/Navigation/NavigationTest.php Added: tests/Zend/View/Helper/Navigation/_files/expected/menu/translated_one_page_without_translator.html
Posted by Frank Brückner (frosch) on 2011-09-27T18:00:26.000+0000
Hi Tomek, why the container must be changed?
Posted by Tomek Pęszor (admirau) on 2011-09-29T07:22:39.000+0000
When you want to add a page, which is already translated, currently there's no option to disable translation just for this particular page container on the pre-view helper level (without iteration).
Posted by Frank Brückner (frosch) on 2012-03-21T20:56:03.000+0000
Patch and unit tests from Tomek added.
Have you found an issue?
See the Overview section for more details.