lang = 'en'; } else { $this->lang = $lang; } if (USE_DEPRECATED_TEMPLATE_FOLDERS === true) { if (is_dir(LAYOUT.$path.LANG)) { $path = LAYOUT.$path.LANG; } elseif (!is_dir($path)) { $path = ''; } } else { // override path check if (!is_dir($path)) { $path = INCLUDES.LANG.CONTENT_PATH; } } $this->mofile = $path.$this->lang.".mo"; // check if get a readable mofile if (is_readable($this->mofile)) { $this->input = new FileReader($this->mofile); } else { $this->input = false; } $this->l10n = new GetTextReader($this->input); } // reloads the mofile, if the location of the lang file changes public function l10nReloadMOfile($lang, $path = DEFAULT_TEMPLATE) { $success = false; $old_mofile = $this->mofile; $old_lang = $this->lang; $this->lang = $lang; if (USE_DEPRECATED_TEMPLATE_FOLDERS === true) { if (is_dir(LAYOUT.$path.LANG)) { $path = LAYOUT.$path.LANG; } elseif (!is_dir($path)) { $path = ''; } } else { // override path check if (!is_dir($path)) { $path = INCLUDES.LANG.CONTENT_PATH; } } $this->mofile = $path.$this->lang.".mo"; // check if get a readable mofile if (is_readable($this->mofile)) { $this->input = new FileReader($this->mofile); $this->l10n = new GetTextReader($this->input); // we successfully loaded $success = true; } else { // else fall back to the old ones $this->mofile = $old_mofile; $this->lang = $old_lang; } return $success; } public function __($text) { return $this->l10n->translate($text); } public function __e($text) { echo $this->l10n->translate($text); } // Return the plural form. public function __ngettext($single, $plural, $number) { return $this->l10n->ngettext($single, $plural, $number); } public function __getLang() { return $this->lang; } public function __getMoFile() { return $this->mofile; } } // __END__