dict_backend)) { $this->dict_backend = new lmbQtDictionaryBackend(); if(defined('LIMB_VAR_DIR')) { $this->dict_backend->setCacheDir(LIMB_VAR_DIR); $this->dict_backend->useCache(); } } return $this->dict_backend; } function setDictionaryBackend($backend) { $this->dict_backend = $backend; } function getLocale() { if(!$this->current_locale) $this->current_locale = 'en_US'; return $this->current_locale; } function setLocale($locale) { $this->current_locale = $locale; } function getLocaleObject($locale = null) { if(!$locale) $locale = $this->getLocale(); if(!isset($this->locale_objects[$locale])) $this->locale_objects[$locale] = $this->createLocaleObject($locale); return $this->locale_objects[$locale]; } function addLocaleObject($obj, $locale = null) { if(!$locale) $locale = $obj->getLocaleString(); $this->locale_objects[$locale] = $obj; } function createLocaleObject($locale) { $file = $this->toolkit->findFileAlias($locale . '.ini', LIMB_LOCALE_INCLUDE_PATH, 'i18n'); if(defined('LIMB_VAR_DIR')) return new lmbLocale($locale, new lmbCachedIni($file, LIMB_VAR_DIR . '/locale/')); else return new lmbLocale($locale, new lmbIni($file)); } function getDictionary($locale, $domain) { if(!isset($this->dictionaries[$locale . '@' . $domain])) { $backend = $this->getDictionaryBackend(); $this->dictionaries[$locale . '@' . $domain] = $backend->load($locale, $domain); } return $this->dictionaries[$locale . '@' . $domain]; } function setDictionary($locale, $domain, $dict) { $this->dictionaries[$locale . '@' . $domain] = $dict; } function translate($text, $arg1 = null, $arg2 = null) { $locale = $this->getLocale(); $domain = 'default'; $attributes = null; if(is_array($arg1)) { $attributes = $arg1; if(is_string($arg2)) $domain = $arg2; } elseif(is_string($arg1)) $domain = $arg1; if($dict = $this->getDictionary($locale, $domain)) return $dict->translate($text, $attributes); else return $text; } } ?>