Issue Type: Bug Created: 2009-05-19T06:37:47.000+0000 Last Updated: 2009-05-21T12:56:54.000+0000 Status: Resolved Fix version(s): - 1.9.0 (31/Jul/09)
Reporter: Sven Jansen (sjansen) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate
Related issues: Attachments: - patch.diff
In the public function translate of Zend_View_Helper_Translate the options count should be updated after every change in options array. This is not really the case. This can lead into problems with the last return "return vsprintf($message, $options)".
As an example i have a messageId like 'translate-me' which should be translated into two languages.
de - translate-me = 'Dies ist 100%tig übersetzt' en - translate-me = 'This is 100% translated'
The % in both aren't placeholders for vsprintf, they are just what they are.
So if I show both translations on one site for translation purposes, I'll render them in a view with $this->translate('translate-me','de') and $this->translate('translate-me','en').
Now the bug comes into game. The translate function won't return the translation, it will throw an Exception "Warning: vsprintf() [function.vsprintf]: Too few arguments in...".
What happened is that the $count variable in the translate function is fixed to options count value before the locale is popped of the end of the options array. The $count value is used for deciding return the translated message if it's 0, but in this case it cant be 0. So the function goas by and tries to return it as a vsprintf string. but there are no more options (the locale gets popped of the options).
I'll provide a patch which should fix this without affecting anything else :)
Posted by Thomas Weidner (thomas) on 2009-05-21T12:41:39.000+0000
This patch does not work and breaks existing unittests.
Posted by Thomas Weidner (thomas) on 2009-05-21T12:56:54.000+0000
Fixed with r15667
Have you found an issue?
See the Overview section for more details.