本帖最后由 nenge 于 2012-1-4 12:48 编辑
修改方法
涉及官方两份核心文件
class_template.php
function_core.php
============
我的数据库记录格式
- $_G['nenge']['stylelang'] = array (
- 'data' =>
- array (
- 'tc' =>
- array (
- 'name' => '繁体语言',
- 'dir' => 'source/lang_tc/',
- ),
- 'en' =>
- array (
- 'name' => '英语语言',
- 'dir' => 'source/lang_en/',
- ),
- ),
- 'lang' =>
- array (
- 0 => 'tc',
- 1 => 'en',
- ),
- 'all' => 'tc:繁体语言,en:英语语言',
- );
复制代码 假设我的数据文件在 /source/lang.php
===========
修改文件
class_template.php
查找
function languagevar($var) {
$vars = explode(':', $var);
$isplugin = count($vars) == 2;
if(!$isplugin) {
!isset($this->language['inner']) && $this->language['inner'] = array();
$langvar = &$this->language['inner'];
} else {
!isset($this->language['plugin'][$vars[0]]) && $this->language['plugin'][$vars[0]] = array();
$langvar = &$this->language['plugin'][$vars[0]];
$var = &$vars[1];
}
if(!isset($langvar[$var])) {
$lang = array();
@include DISCUZ_ROOT.'./source/language/lang_template.php';
$this->language['inner'] = $lang;
if(!$isplugin) {
if(defined('IN_MOBILE')) {
list($path) = explode('/', str_replace('mobile/', '', $this->file));
} else {
list($path) = explode('/', $this->file);
}
@include DISCUZ_ROOT.'./source/language/'.$path.'/lang_template.php';
$this->language['inner'] = array_merge($this->language['inner'], $lang);
if(defined('IN_MOBILE')) {
@include DISCUZ_ROOT.'./source/language/mobile/lang_template.php';
$this->language['inner'] = array_merge($this->language['inner'], $lang);
}
} else {
global $_G;
if(empty($_G['config']['plugindeveloper'])) {
loadcache('pluginlanguage_template');
} elseif(!isset($_G['cache']['pluginlanguage_template'][$vars[0]]) && preg_match("/^[a-z]+[a-z0-9_]*$/i", $vars[0])) {
if(@include(DISCUZ_ROOT.'./data/plugindata/'.$vars[0].'.lang.php')) {
$_G['cache']['pluginlanguage_template'][$vars[0]] = $templatelang[$vars[0]];
} else {
loadcache('pluginlanguage_template');
}
}
$this->language['plugin'][$vars[0]] = $_G['cache']['pluginlanguage_template'][$vars[0]];
}
}
if(isset($langvar[$var])) {
return $langvar[$var];
} else {
return '!'.$var.'!';
}
}
替换成
function languagevar($var) {
$vars = explode(':', $var);
$isplugin = count($vars) == 2;
if(!$isplugin) {
!isset($this->language['inner']) && $this->language['inner'] = array();
$langvar = &$this->language['inner'];
} else {
!isset($this->language['plugin'][$vars[0]]) && $this->language['plugin'][$vars[0]] = array();
$langvar = &$this->language['plugin'][$vars[0]];
$var = &$vars[1];
}
/*nenge strat*/
include DISCUZ_ROOT.'source/lang.php';
$langid = $_GET['languagename']?$_GET['languagename']_COOKIE['languagename'];
if(in_array($langid,$_G['nenge']['stylelang']['lang']) && is_dir(DISCUZ_ROOT.'./'.$_G['nenge']['stylelang']['data'][$langid]['dir'])){
$langpath = DISCUZ_ROOT.'./'.$_G['nenge']['stylelang']['data'][$langid]['dir'];
}else{
$langpath = DISCUZ_ROOT.'./source/language/';
}
/*nenge end*/
if(!isset($langvar[$var])) {
$lang = array();
/*nenge strat*/
@include $langpath.'lang_template.php';
/*nenge end*/
$this->language['inner'] = $lang;
if(!$isplugin) {
if(defined('IN_MOBILE')) {
list($path) = explode('/', str_replace('mobile/', '', $this->file));
} else {
list($path) = explode('/', $this->file);
}
/*nenge strat*/
@include $langpath.$path.'/lang_template.php';
/*nenge end*/
$this->language['inner'] = array_merge($this->language['inner'], $lang);
if(defined('IN_MOBILE')) {
/*nenge strat*/
@include $langpath.'mobile/lang_template.php';
/*nenge end*/
$this->language['inner'] = array_merge($this->language['inner'], $lang);
}
} else {
global $_G;
if(empty($_G['config']['plugindeveloper'])) {
loadcache('pluginlanguage_template');
} elseif(!isset($_G['cache']['pluginlanguage_template'][$vars[0]]) && preg_match("/^[a-z]+[a-z0-9_]*$/i", $vars[0])) {
if(@include(DISCUZ_ROOT.'./data/plugindata/'.$vars[0].'.lang.php')) {
$_G['cache']['pluginlanguage_template'][$vars[0]] = $templatelang[$vars[0]];
} else {
loadcache('pluginlanguage_template');
}
}
$this->language['plugin'][$vars[0]] = $_G['cache']['pluginlanguage_template'][$vars[0]];
}
}
if(isset($langvar[$var])) {
return $langvar[$var];
} else {
return '!'.$var.'!';
}
}
|