From: Meik S. <acy...@ph...> - 2009-08-01 11:02:06
|
Author: acydburn Date: Sat Aug 1 12:01:18 2009 New Revision: 9901 Log: Fallback options for missing language files. (Bug #38575 - Patch by EXreaction) Modified: branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html branches/phpBB-3_0_0/phpBB/includes/session.php Modified: branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html ============================================================================== *** branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html (original) --- branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html Sat Aug 1 12:01:18 2009 *************** *** 254,259 **** --- 254,260 ---- </li> <li>[Feature] Display version check on ACP main page.</li> <li>[Feature] Ability to copy permissions from one forum to several other forums.</li> + <li>[Feature] Fallback options for missing language files. (Bug #38575 - Patch by EXreaction)</li> </ul> <a name="v304"></a><h3>1.ii. Changes since 3.0.4</h3> Modified: branches/phpBB-3_0_0/phpBB/includes/session.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/session.php (original) --- branches/phpBB-3_0_0/phpBB/includes/session.php Sat Aug 1 12:01:18 2009 *************** *** 2006,2011 **** --- 2006,2039 ---- $language_filename = $this->lang_path . $this->lang_name . '/' . (($use_help) ? 'help_' : '') . $lang_file . '.' . $phpEx; } + if (!file_exists($language_filename)) + { + global $config; + + if ($this->lang_name == 'en') + { + // The user's selected language is missing the file, the board default's language is missing the file, and the file doesn't exist in /en. + $language_filename = str_replace($this->lang_path . 'en', $this->lang_path . $this->data['user_lang'], $language_filename); + trigger_error('Language file ' . $language_filename . ' couldn\'t be opened.', E_USER_ERROR); + } + else if ($this->lang_name == basename($config['default_lang'])) + { + // Fall back to the English Language + $this->lang_name = 'en'; + $this->set_lang($lang, $help, $lang_file, $use_db, $use_help); + } + else if ($this->lang_name == $this->data['user_lang']) + { + // Fall back to the board default language + $this->lang_name = basename($config['default_lang']); + $this->set_lang($lang, $help, $lang_file, $use_db, $use_help); + } + + // Reset the lang name + $this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']); + return; + } + // Do not suppress error if in DEBUG_EXTRA mode $include_result = (defined('DEBUG_EXTRA')) ? (include $language_filename) : (@include $language_filename); *************** *** 2262,2272 **** if ($group = remove_newly_registered($this->data['user_id'], $this->data)) { $this->data['group_id'] = $group; ! } $this->data['user_permissions'] = ''; $this->data['user_new'] = 0; ! return true; } } --- 2290,2300 ---- if ($group = remove_newly_registered($this->data['user_id'], $this->data)) { $this->data['group_id'] = $group; ! } $this->data['user_permissions'] = ''; $this->data['user_new'] = 0; ! return true; } } |