Pascal Opitz posted a nice little snippet; Just a quick snippet to have dynamic parameters in the underscore function, without having to write sprintf every time.
<?php class Translate extends Zend_Translate { public function _() { $args = func_get_args(); $num = func_num_args(); $adapter = $this->getAdapter(); $args[0] = $adapter->_($args[0]); if($num <= 1) { return $args[0]; } return call_user_func_array('sprintf', $args); } }
Usage would be something like the following:
$t = new Translate('array', $array_translation, $lang); echo $t->_('My name is %s', 'Pascal'); echo $t->_('I have a %s and a %s', 'Cat', 'Horse');
Note: The above little snippet solves one of the major gripes I have with the default _() function.
Entdeckung des Tages: Zend_Translate + Custom View_Helper = Coolness.