From: Roland Häder Date: Tue, 6 Oct 2009 20:26:19 +0000 (+0000) Subject: Function loadLanguageFile() does now support extensions X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=a7c7b8307405aa270a38ce4e363c41b3d1c9c745;p=mailer.git Function loadLanguageFile() does now support extensions --- diff --git a/inc/extensions.php b/inc/extensions.php index c9865d7f83..1b17f1101f 100644 --- a/inc/extensions.php +++ b/inc/extensions.php @@ -79,21 +79,8 @@ function LOAD_EXTENSION ($ext_name, $EXT_LOAD_MODE = '', $EXT_VER = '', $dry_run return false; } // END - if - // Construct FQFN for language file - $langInclude = sprintf("inc/language/%s_%s.php", $ext_name, getLanguage()); - - // Is this include there? - if ((isFileReadable($langInclude)) && (!isset($GLOBALS['ext_loaded']['lang'][$ext_name]))) { - // Then load it - //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "--- Language loaded."); - $GLOBALS['ext_loaded']['lang'][$ext_name] = true; - loadIncludeOnce($langInclude); - } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) { - // No language file is not so good... - DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no language file or we cannot read from it. lang=%s", - $ext_name, getLanguage() - )); - } + // Load extension's own language file + loadLanguageFile($ext_name); // Construct FQFN for functions file $funcsInclude = sprintf("inc/libs/%s_functions.php", $ext_name); diff --git a/inc/language-functions.php b/inc/language-functions.php index 5cde4b6ebe..c2cde5f34f 100644 --- a/inc/language-functions.php +++ b/inc/language-functions.php @@ -83,7 +83,7 @@ function getLanguage () { $ret = $GLOBALS['cache_array']['language']; } elseif (!empty($lang)) { // Check if main language file does exist - if (isFileReadable(constant('PATH') . 'inc/language/'.$lang.'.php')) { + if (isFileReadable(constant('PATH') . 'inc/language/' . $lang . '.php')) { // Okay found, so let's update cookies setLanguage($lang); } // END - if @@ -112,7 +112,9 @@ function setLanguage ($lang) { } // Load the current language file or fixes it to 'de' -function loadLanguageFile () { +// If ext_name is empty, load general language support, else load extension's +// language file. +function loadLanguageFile ($ext_name = '') { // Try to get language from session $mx_lang = getSession('mx_lang'); @@ -120,20 +122,34 @@ function loadLanguageFile () { if (is_null($mx_lang)) $mx_lang = getConfig('DEFAULT_LANG'); // Generate filename - $INC = sprintf("inc/language/%s.php", SQL_ESCAPE($mx_lang)); + if (empty($ext_name)) { + // Generic + $languageInclude = sprintf("inc/language/%s.php", SQL_ESCAPE($mx_lang)); + } else { + // Extension's language file + $languageInclude = sprintf("inc/language/%s_%s.php", $ext_name, getLanguage()); + } - // Look for file - if (!isIncludeReadable($INC)) { + // Look for file if no extension name is provided + if ((empty($ext_name)) && (isIncludeReadable($languageInclude) === false)) { // Switch to default (DO NOT CHANGE!!!) setLanguage('de'); - $INC = 'inc/language/de.php'; + $languageInclude = 'inc/language/de.php'; // And set it temporarily setConfigEntry('DEFAULT_LANG', 'de'); } // END - if - // Load language file - loadIncludeOnce($INC); + // Is the file there? + if (isIncludeReadable($languageInclude)) { + // Load language file + loadIncludeOnce($languageInclude); + } elseif ((isDebugModeEnabled()) && ($ext_name != 'sql_patches') && (substr($ext_name, 0, 10) != 'admintheme')) { + // No language file is not so good... + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("WARNING: Extension %s has no language file or we cannot read from it. lang=%s", + $ext_name, getLanguage() + )); + } // Check for installation mode if ((isInstalling()) || (!isInstalled()) || (!isAdminRegistered())) {