首页 > Zencart > zencart不同域名绑定不同语言的方法

zencart不同域名绑定不同语言的方法

描述:www.zcadmin.com 访问的是默认语言, cn.zcadmin.com 访问的是汉语, jp.zcadmin.com 访问的是日语等等。
优势:语言能独立成站。方便搜索引擎收录。
代码:
修改文件 \includes\init_includes\init_languages.php

//ZenCart网店系统工具的开发与应用,小工具解决繁琐问题,使Zen Cart应用简单化。
//By www.zcadmin.com
<?
if (!defined(‘IS_ADMIN_FLAG’)) {
die(‘Illegal Access’);
}

if (!isset($_SESSION[‘language’]) || isset($_GET[‘language’])) {
$lng = new language();
if (isset($_GET[‘language’]) && zen_not_null($_GET[‘language’])) {
$lng->set_language($_GET[‘language’]);
} else {
if (LANGUAGE_DEFAULT_SELECTOR==’Browser’) {
$lng->get_browser_language();
} else {
$lng->set_language(DEFAULT_LANGUAGE);
}
}

if($_SERVER[‘HTTP_HOST’] == ‘www.open-cart.com’ || $_SERVER[‘HTTP_HOST’] == ‘open-cart.com’){
$_SESSION[‘languages_id’] = 1;
$_SESSION[‘language’] = ‘english’;
$_SESSION[‘languages_code’] = ‘en’;
}
else if($_SERVER[‘HTTP_HOST’] == ‘fr.open-cart.com’){
$_SESSION[‘languages_id’] = 2;
$_SESSION[‘language’] = ‘french’;
$_SESSION[‘languages_code’] = ‘fr’;
}
else if($_SERVER[‘HTTP_HOST’] == ‘de.open-cart.com’){
$_SESSION[‘languages_id’] = 3;
$_SESSION[‘language’] = ‘german’;
$_SESSION[‘languages_code’] = ‘de’;
}
else if($_SERVER[‘HTTP_HOST’] == ‘it.open-cart.com’){
$_SESSION[‘languages_id’] = 5;
$_SESSION[‘language’] = ‘italian’;
$_SESSION[‘languages_code’] = ‘it’;
}
else if($_SERVER[‘HTTP_HOST’] == ‘pt.open-cart.com’){
$_SESSION[‘languages_id’] = 6;
$_SESSION[‘language’] = ‘portugues’;
$_SESSION[‘languages_code’] = ‘pt’;
}
else if($_SERVER[‘HTTP_HOST’] == ‘es.open-cart.com’){
$_SESSION[‘languages_id’] = 7;
$_SESSION[‘language’] = ‘spanish’;
$_SESSION[‘languages_code’] = ‘es’;
}
else{
$_SESSION[‘language’] = (zen_not_null($lng->language[‘directory’]) ? $lng->language[‘directory’] : ‘english’);
$_SESSION[‘languages_id’] = (zen_not_null($lng->language[‘id’]) ? $lng->language[‘id’] : 1);
$_SESSION[‘languages_code’] = (zen_not_null($lng->language[‘code’]) ? $lng->language[‘code’] : ‘en’);
}
}
?>

分类:Zencart 标签:, ,
  1. 还没有评论。
  1. No trackbacks yet.

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: