当前位置:

制作ecshop中英文切换简繁切换版面

对于从事外贸的商城网站来说,外文版面必不可以少,如何使用ECSHOP进行商城网站建设时,能够在自己的网站上拥有中英文切换|简繁切换版面呢?
ecshop中英文切换|简繁切换版面

下面是实现ecshop中英文切换|简繁切换版面的方法:

  1. 打开ECSHOP程序,找到includds/init.php这个文件,然后用Dreamweaver cs5打开它;
  2. 使用快捷键“CTRL+F”查找以下这二段代码并将它们删除:
    require(ROOT_PATH . 'languages/' . $_CFG['lang'] . '/common.php'); if ($_CFG['shop_closed'] == 1) { header('Content-type: text/html; charset='.EC_CHARSET); die( $_LANG['shop_closed'], $_CFG['close_comment'] ); }
  3. 再用快捷键“CTRL+F”找到以下这段代码:
    if ((DEBUG_MODE & 1) == 1)
  4. 在这段代码的上方粘贴这段代码:
    if (!defined('INIT_NO_USERS')) { include(ROOT_PATH . 'includes/cls_session.php'); $sess = new cls_session($db, $ecs->table('session'), $ecs->table('session_data')); define('SESS_ID', $sess->get_session_id()); }
  5. 在这段代码的下方粘贴下面的这段中英文切换和简繁体切换代码,用于实现中英文版面;
    if(!empty($_REQUEST['lang'])){
    $_SESSION['lang']=$_REQUEST['lang'];
    }
    if (!empty($_SESSION['lang']))
    {
    switch($_SESSION['lang']){
    case 'zh_cn':
    $_CFG['lang']="zh_cn";
    break;
    case 'zh_tw':
    $_CFG['lang']="zh_tw";
    break;
    case 'en_us':
    $_CFG['lang']="en_us";
    break;
    }
    }
    require(ROOT_PATH . 'languages/' . $_CFG['lang'] . '/common.php');
    if ($_CFG['shop_closed'] == 1)
    {
    header('Content-type: text/html; charset='.EC_CHARSET);
    die( $_LANG['shop_closed'], $_CFG['close_comment'] );
    }
  6. 最后就是在网页页面调用中英文切换的按钮了,一般情况下这个功能按钮都是放在网站的顶部的。所以我们用DW打开themes/default/library/page_header.lbi ,在
    <div class="topNavR"></div>

    位置上方使用以下的调用代码:

    <a href="?lang=zh_cn">简体 </a>
    <a href="?lang=zh_tw">繁体 </a>
    <a href="?lang=en_us">英文 </a>
  7. 到网站后台清空一下缓存,再查一下前台的页面效果了,就会多了中文简体,中文繁体,English的按钮。

相关文章:wordpress多语言插件,实现(中英文)多语言版本网站

《“制作ecshop中英文切换简繁切换版面”》 有 1 条评论

  1. 学习建网站学员 征途说道:

    1.在前台文件夹include中找到init.phP文件,然后找到:

    require(ROOT_PATH . ‘languages/’ . $_CFG['lang'] . ‘/common.php’);

    然后再填写上面这些代码:

    //获取传入的lang -&gt;写入到cookie-&gt;跳转//中英文版
    if($_GET['lang']&amp;&amp;in_array($_GET['lang'],array(‘zh_cn’,'en_us’,'zh_tw’)))
    {
    setcookie(‘lang’,$_GET['lang'],0);
    header(“location:”.PHP_SELF);
    }
    $_CFG['lang']=$_COOKIE['lang']?$_COOKIE['lang']:’zh_cn’;///$_CFG['lang']=’en_us’;//英文版
    //echo $_COOKIE['lang'];
    /* 载入语言文件 */
    //$_CFG['lang']=$_GET['lang'];
    require(ROOT_PATH . ‘languages/’ . $_CFG['lang'] . ‘/common.php’);

    2.在找到头部模板文件
    在 themes/default/library/page_header.lib 相应的位置(你自己需要的地方) 添加上对应的中文链接和英文链接,代码如下:

    <a href="”../index.php?lang=zh_cn”" rel="nofollow">中文版&nbsp;</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="”../index.php?lang=en_us”" rel="nofollow">英文版</a>

    3.前台预览会出现Notice,和 Warning

    Notice: Undefined index: lang in D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php on line 120
    Warning: Cannot modify header information – headers already sent by (output started at D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php:120) in D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php on line 176
    Warning: Cannot modify header information – headers already sent by (output started at D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php:120) in D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php on line 177
    Warning: Cannot modify header information – headers already sent by (output started at D:\shanmaoweb\shanmao\mylocalhost\afu\includes\init.php:120) in D:\shanmaoweb\shanmao\mylocalhost\afu\includes\cls_template.php on line 58

    我们可以在init.php中屏蔽,在init.php的前几行找到(大概在20行。)

    error_reporting(E_ALL);//E_ALL表示所有的都打开,错误等级设置

    改成

    error_reporting(E_ALL ^ E_NOTICE );//除去 E_NOTICE 之外的所有错误信息

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注