/** * @param $key * @param array $params * @return string */ public function translate($key, array $params = array()) { // if there is no translator, simplt return the key if (is_null($this->translator)) { return $key; } // try to translate $translation = $this->translator->translate($key, $params); // TODO: nested translations: check returned translation to contain a sub-translation, and while so, keep translating the sub-translation // make sure to always return the key if no translation could be found return is_null($translation) ? $key : $translation; }
/** * @return TranslationHandler */ public function getTranslator() { if (is_null($this->translationHandler)) { $this->translationHandler = new TranslationHandler($this->getTranslationWildcardReplacer()); $this->translationHandler->setTranslator($this->getDefaultTranslator()); } return $this->translationHandler; }