* @license PHP License * @package WB * @subpackage db */ WBClass::load('WBDatasource_Decorator'); /** * Simple datasource decorator: Translator * * @version 0.1.1 * @package WB * @subpackage db */ class WBDatasource_Decorator_Translator extends WBDatasource_Decorator { /** * decorator's parameter list * * Parameters: * - domain - text domain or default * - columns: list of columns to translate * * @var array */ protected $parameter = array( 'domain' => null, 'column' => array(), ); /** * setup column buffers */ public function onStart(&$item) { } /** * actually decorate list item * * @param array $item * @return void */ public function decorate(&$item) { foreach ($this->parameter['column'] as $c) { if (empty($this->parameter['domain'])) { $item[$c] = patI18n::gettext($item[$c]); } else { $item[$c] = patI18n::dgettext($this->parameter['domain'], $item[$c]); } } } } ?>