ZF-12167: Backport to ZF 1.x


A backport to ZF 1.x would be very helpful as for now one has to overload all adapters to use the fallback routing with plurals.


There are no plans to do this, in large part due to the fact that the support required BC breaks in order to implement.

Well, there could be a simple solution: make it dependent on a static variable. When the variable is set to TRUE it useses the BC-breaking correct $origMsgId, otherwise it behaves as currently expected. Currently it is an undesirable situation where one has to copy all adapters to his own lib just to override the translate() method with the fixed version whereas my suggested fix would be as simple as calling Zend_Translate::useFixForBug11173(TRUE);

Without fixing or copying all adapters one has to check in every call to translate (with plurals) if the returned value is a string or an array. A real show-stopper for any new (bigger) project.

Implementation code for the fix:

117: protected $_translate = array(); +
+ protected static $_useFixForBug11173 = FALSE; +
+ public static function useFixForBug11173($useFix = FALSE) { + self::$_useFixForBug11173 = (bool)$useFix; + } +
+ public static function getFixForBug11173() { + return self::$_useFixForBug11173; + }

705: - $plural = null; 705: + $plural = NULL; + $originalMessageId = $messageId;

732: - return $this->translate($messageId, $this->_options['route'][$locale]); 732: + return $this->translate(self::$_useFixForBug11173 ? $originalMessageId : $messageId, $this->_options['route'][$locale]);

790: - return $this->translate($messageId, $this->_options['route'][$locale]); 790: + return $this->translate(self::$_useFixForBug11173 ? $originalMessageId : $messageId, $this->_options['route'][$locale]);