/** * Translator instante * * @return Zend_Translate */ public static function getInstance() { if (self::$_instance === null) { self::$_instance = new self(); } return self::$_instance; }
/** * Constructor * @param array $options */ public function __construct($options = array()) { if ($options instanceof Zend_Locale) { $this->locale = $options; } elseif (is_string($options)) { $this->date_format = $options; } elseif (is_array($options)) { foreach ($options as $k => $v) { switch ($k) { case 'locale': $this->locale = $v; break; case 'date_format': $this->date_format = $v; break; case 'type': case 'format_type': $this->type = $v; break; default: throw new Bvb_Grid_Exception(Bvb_Grid_Translator::getInstance()->__("Unknown option '{$k}'.")); } } } elseif (Zend_Registry::isRegistered('Zend_Locale')) { $this->locale = Zend_Registry::get('Zend_Locale'); } }
public function testSetTranslatorFromBvbTranslator() { $english = array('Name_of' => 'Barcelos', 'message2' => 'message2', 'message3' => 'message3'); $german = array('Fmessage1' => 'Nachricht1', 'message2' => 'Nachricht2', 'message3' => 'Nachricht3'); $translate = new Zend_Translate('array', $english, 'en'); Bvb_Grid_Translator::getInstance()->setTranslator($translate); $this->grid->setTranslator($translate); $this->assertInstanceOf('Zend_Translate', $this->grid->getTranslator()); }
/** * Formats a given value * @see library/Bvb/ Grid/Formatter/Bvb_Grid_Formatter_FormatterInterface::format() */ public function format($value) { $translate = Bvb_Grid_Translator::getInstance(); return (bool) $value ? $translate->__('Yes') : $translate->__('No'); }
public function export($exportDeploy, $images, $url, $gridId) { $exp = ''; foreach ($exportDeploy as $format => $export) { $caption = sprintf(Bvb_Grid_Translator::getInstance()->__('Export to %s format'), $export['caption']); $export['newWindow'] = isset($export['newWindow']) ? $export['newWindow'] : true; $class = isset($export['cssClass']) ? 'class="' . $export['cssClass'] . '"' : ''; $blank = $export['newWindow'] == false ? '' : "target='_blank'"; if (strlen($images) > 1) { if (isset($export['img'])) { $export['img'] = $images . $export['img']; } else { $export['img'] = $images . $format . '.gif'; } } if (isset($export['img'])) { $exp .= "<a title='{$caption}' {$class} {$blank} href='{$url}/_exportTo{$gridId}/{$format}'>\n <img alt='{$export['caption']}' src='{$export['img']}' border='0'></a>"; } else { $exp .= "<a title='{$caption}' {$class} {$blank} href='{$url}/_exportTo{$gridId}/{$format}'>" . $export['caption'] . "</a>"; } } $this->exportWith = 25 * count($exportDeploy); $this->paginationWith = 630 + (10 - count($exportDeploy)) * 20; $this->export = $exp; return $exp; }
/** * Check if a string is available * * @param string $message Message to check if it's translated * * @return bool */ protected function isTranslated($message) { return Bvb_Grid_Translator::getInstance()->isTranslated($message); }
/** * Translates a given dtring * * @param string $message * * @return string */ public function __($message) { return Bvb_Grid_Translator::getInstance()->__($message); }