/** * Load internationalization string files * * */ public function loadLanguageFiles() { $culture_file = getShadowedPath(PA::$config_path . '/i18n.xml'); $culture_data = new XmlConfig($culture_file); if ($culture_data->docLoaded) { PA::$culture_data = $culture_data->asArray(); } else { throw new BootStrapException("Error - Can't load \"{$culture_file}\" culture file.", BootStrapException::UNRECOVERABLE_BOOT_EXCEPTION); } $this->installed_languages = $this->getLanguagesList(); session_start(); if (!empty($this->request_data['lang'])) { if (array_key_exists($this->request_data['lang'], $this->installed_languages)) { $this->current_lang = $this->request_data['lang']; $_SESSION['user_lang'] = $this->current_lang; } } else { if (isset($_SESSION['user_lang'])) { $this->current_lang = $_SESSION['user_lang']; } else { if (PA::$config->pa_installed) { $net_info = get_network_info(); $net_settings = unserialize($net_info->extra); $this->current_lang = isset($net_settings['default_language']) ? $net_settings['default_language'] : 'english'; } } } session_commit(); if ($this->current_lang) { PA::$language = $this->current_lang; } ob_start(); global $TRANSLATED_STRINGS; $strings_file = getShadowedPath("web/languages/" . PA::$language . "/strings.php"); try { if (file_exists($strings_file)) { eval('?>' . (require_once $strings_file)); } $msg_handler = getShadowedPath("web/languages/" . PA::$language . "/MessagesHandler.php"); if (file_exists($msg_handler)) { eval('?>' . (require_once $msg_handler)); } else { eval('?>' . (require_once getShadowedPath("web/languages/english/MessagesHandler.php"))); } } catch (Exception $e) { // Either an invalid language was selected, or one (e.g. English) without a strings.php file. $TRANSLATED_STRINGS = array(); throw new BootStrapException($e->message, 1); } return ob_get_clean(); }