/** * Translates a string and handles parameter replacements * * @param string $string String to translate * @param array $parameters An array of parameters * * @return string Translated string */ public function translate($string, array $parameters = array()) { $result = strtolower($string); if (empty($result)) { $result = ''; } elseif (isset($this->_alias_catalogue[$result])) { $result = $this->_translation_helper->_($this->_alias_catalogue[$result]); } else { if (substr($string, 0, strlen($this->_prefix)) === $this->_prefix) { $key = $string; } else { $key = $this->getKey($string); } $result = $this->_translation_helper->_($this->_translation_helper->hasKey($key) ? $key : $string); } // Joomla uses _QQ_ instead of " in language files // and 1.5 does not handle the conversion itself if (version_compare(JVERSION, '1.6', '<')) { $result = str_replace('"_QQ_"', '"', $result); } return parent::translate($result, $parameters); }
/** * Sets the locale * * @param string $locale * @return KTranslatorAbstract */ public function setLocale($locale) { if ($this->_locale != $locale) { parent::setLocale($locale); //Load the koowa translations $this->load('com:koowa'); } return $this; }