_adapter === null) { $translate = Front::getInstance()->getBootstrap()->getResource('translate'); $this->setAdapter($translate); } return $this->_adapter; } /** * * set translation adapter * * @param mixed $adapter * * @return $this * @throws \InvalidArgumentException */ public function setAdapter($adapter) { if ($adapter instanceof TranslateAdapter) { $this->_adapter = $adapter; } else if ($adapter instanceof TranslateObject) { $this->_adapter = $adapter->getAdapter(); } else { throw new \InvalidArgumentException("The translation adapter set in the view helper must be of type \Cube\Translate or \Cube\Translate\Adapter."); } return $this; } /** * * get locale * * @return string */ public function getLocale() { return $this->getAdapter()->getLocale(); } /** * * set locale * * @param string|\Cube\Locale $locale * * @return $this */ public function setLocale($locale) { $this->getAdapter()->setLocale($locale); return $this; } /** * * returns translated string * * @param string $message * * @return string */ public function translate($message = null) { if (!$message) { return ''; } return $this->getAdapter()->translate($message); } }