代码function lang($file, $langvar = null, $vars = array(), $default = null) { echo $file.':'.$langvar.':'; global $_G; $fileinput = $file; list($path, $file) = explode('/', $file); if(!$file) { echo('1-'); $file = $path; $path = ''; } if(strpos($file, ':') !== false) { echo('2-'); $path = 'plugin'; list($file) = explode(':', $file); } if($path != 'plugin') { echo('3-'); $key = $path == '' ? $file : $path.'_'.$file; if(!isset($_G['lang'][$key])) { echo('31-'); include DISCUZ_ROOT.'./source/language/'.($path == '' ? '' : $path.'/').'lang_'.$file.'.php'; var_dump(DISCUZ_ROOT.'./source/language/'.($path == '' ? '' : $path.'/').'lang_'.$file.'.php'); $_G['lang'][$key] = $lang; } if(defined('IN_MOBILE') && !defined('TPL_DEFAULT')) { echo('32-'); include DISCUZ_ROOT.'./source/language/mobile/lang_template.php'; $_G['lang'][$key] = array_merge($_G['lang'][$key], $lang); } if($file != 'error' && !isset($_G['cache']['pluginlanguage_system'])) { echo('33-'); loadcache('pluginlanguage_system'); } if(!isset($_G['hooklang'][$fileinput])) { echo('34-'); if(isset($_G['cache']['pluginlanguage_system'][$fileinput]) && is_array($_G['cache']['pluginlanguage_system'][$fileinput])) { $_G['lang'][$key] = array_merge($_G['lang'][$key], $_G['cache']['pluginlanguage_system'][$fileinput]); } $_G['hooklang'][$fileinput] = true; } $returnvalue = &$_G['lang']; } else { echo('4-'); if(empty($_G['config']['plugindeveloper'])) { loadcache('pluginlanguage_script'); } elseif(!isset($_G['cache']['pluginlanguage_script'][$file]) && preg_match("/^[a-z]+[a-z0-9_]*$/i", $file)) { if(@include(DISCUZ_ROOT.'./data/plugindata/'.$file.'.lang.php')) { $_G['cache']['pluginlanguage_script'][$file] = $scriptlang[$file]; } else { loadcache('pluginlanguage_script'); } } $returnvalue = & $_G['cache']['pluginlanguage_script']; $key = &$file; } $return = $langvar !== null ? (isset($returnvalue[$key][$langvar]) ? $returnvalue[$key][$langvar] : null) : $returnvalue[$key]; $return = $return === null ? ($default !== null ? $default : $langvar) : $return; $searchs = $replaces = array(); if($vars && is_array($vars)) { echo('5-'); foreach($vars as $k => $v) { $searchs[] = '{'.$k.'}'; $replaces[] = $v; } } if(is_string($return) && strpos($return, '{_G/') !== false) { echo('6-'); preg_match_all('/\{_G\/(.+?)\}/', $return, $gvar); foreach($gvar[0] as $k => $v) { $searchs[] = $v; $replaces[] = getglobal($gvar[1][$k]); } } $return = str_replace($searchs, $replaces, $return); echo('7</br>'); return $return; }
discuz 多语言翻译 lang()
最新推荐文章于 2024-08-11 02:45:08 发布