Issues

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

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

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

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

Added to ZF2 with GH-521.