ZF-12167: Backport to ZF 1.x

Issue Type: Sub-task Created: 2012-04-23T02:37:23.000+0000 Last Updated: 2012-04-23T14:07:22.000+0000 Status: Resolved Fix version(s): Reporter: Gabriel Schuster (g.schuster) Assignee: Thomas Weidner (thomas) Tags: - Zend_Translate

Related issues: Attachments:


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.


Posted by Matthew Weier O'Phinney (matthew) on 2012-04-23T13:44:49.000+0000

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

Posted by Gabriel Schuster (g.schuster) on 2012-04-23T14:07:22.000+0000

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]);

Have you found an issue?

See the Overview section for more details.


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

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