/index.php 首页
// 多语言 if( isset($_GET['language']) && !isset($_SESSION['language_file']) ){ if( in_array($_GET['language'],$cfg_ary_language) ){ $_SESSION['language_file'] = $_GET['language']; }else{ $_SESSION['language_file'] = $cfg_ary_language[0]; } }
/data/common.inc.php
// templates下 新建language/chinese.php,english.php $cfg_ary_language = array('chinese','english'); if(!isset($_SESSION)){ session_start(); } if( isset($_SESSION['language_file']) ){ switch($_SESSION['language_file']){ case 'chinese': $tmp_lang = 'typename'; break; case 'english': $tmp_lang = 'typename2'; break; default: $tmp_lang = $_SESSION['language_file']; } }else{ $tmp_lang = 'typename'; } define('LANGUAGE_TYPENAME',$tmp_lang); unset($tmp_lang);
include/dedetag.class.php里的class DedeTagParse{}内添加
function SetLanguage(){ //--------------------语言替换-------------------------------------- $language_file = DEDETEMPLATE.'/language/'; if( isset($_SESSION['language_file']) ){ $language_file .= $_SESSION['language_file'] . '.php'; }else{ $language_file .= 'chinese.php'; } require ($language_file); $ary_search = array_keys($ary_language); $this->SourceString = str_replace($ary_search,$ary_language,$this->SourceString); /////////////////////////////////////////////////// }
language/chinese.php
//默认中文语言 $ary_language = array( '__typename__' =>'typename', '__en1__' =>'english', '__en2__' =>'English', '__indexf__' =>'首', '__page__' =>'页', '__username__' =>'用户名', '__password__' =>'密 码', '__login__' =>'登录', '__register__' =>'注册', '__question__' =>'常见问题解答', '__bbs__' =>'论坛'
数据库添加英文字段,后台添加英文字段