Issues

ZF-11830: Dynamic locale changing in Zend_View_Helper_Translate can cause unexpected failures

Issue Type: Improvement Created: 2011-10-19T17:38:09.000+0000 Last Updated: 2011-10-27T19:05:38.000+0000 Status: Resolved Fix version(s): - Next Major Release ()

Reporter: Mason Malone (masonm) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate

  • Zend_View

Related issues: Attachments:

Description

The logic in Zend_View_Helper_Translate->translate() that allows changing the locale by passing it as the last parameter can cause normal-looking code to inexplicably fail. For example, take the following view code: bq. $this->translate('num %d name %s', $obj->id, $obj->name)

This will generate "vsprintf(): Too few arguments" errors if $obj->name happens to be a valid locale (e.g. "it"). Personally, I think this behavior should be removed since it violates the principle of least surprise, but that would be a BC-break. I think a good compromise would be to have Zend_View_Helper_Translate->translate() do some additional checking and not treat the last parameter as a locale if doing so would cause a "Too few arguments" error. Here's a patch that implements this: https://gist.github.com/1299031

Comments

Posted by Adam Lundrigan (adamlundrigan) on 2011-10-19T17:47:46.000+0000

You will need to sign and submit a CLA before we can apply your suggested improvement. See here: http://framework.zend.com/wiki/display/…

Posted by Andy Fowler (andyfowler) on 2011-10-19T17:56:36.000+0000

This patch was developed at <www.nutshell.com> -- Mason is another coder here, and I have signed the CLA (for the entire company). Can this patch be submitted under my CLA? Can you update Mason's user account to be covered by the same CLA? Thanks!

Andy Fowler <www.nutshell.com>

Posted by Thomas Weidner (thomas) on 2011-10-27T19:05:38.000+0000

Added to ZF2 with GH-521.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts