/** * Get translation for a specified key * * @param string $key * @param string|null $lang If not specified the current language will be taken * @param bool $returnKeyIfNot If false than null will be returned * @return string|null */ function t($key, $lang = null, $returnKeyIfNot = true) { return CHOQ_LanguageManager::getTranslation($key, $lang, $returnKeyIfNot); }
/** * Set language from current uri * This only happens if url()->languageInUri is true * * @return string|null The determined Language */ static function setLanguageByUri() { if (url()->languageInUri) { $uri = url()->getModifiedUri(false, false, true); foreach (self::$languages as $lang) { if (preg_match("~^/{$lang}(/|\$)~", $uri)) { self::$language = $lang; return $lang; } } } else { error("Could not " . __CLASS__ . "::setLanguageByUri because languageInUri is not set in UrlManager"); } }