【问题标题】:Language Switching in MagentoMagento 中的语言切换
【发布时间】:2010-07-28 14:52:39
【问题描述】:

提前致谢,

我是 Magento 的新手,需要帮助为用户切换语言。当客户访问我的网站时,它应该使用他们的 IP 来确定他们的国家并适当地切换语言。

例如,如果我从法国访问,我的网站应该以法语显示。如果其他人尝试从任何国家/地区尝试该网站,则该网站应使用该国家/地区的当地语言。

-吉特

【问题讨论】:

    标签: php magento


    【解决方案1】:

    我曾经为客户做过一次。这是我所做的。

    必备:PHP 的 GeoIp 库。

    1- 在您的 Magento 管理员中创建与语言相关的商店视图。

    2- 添加过滤系统:

    2a - 编辑主/父主题的 page.xml 布局文件,并在第 35/36 行附近(在句柄中添加:

    <block type="page/html" name="country-filter" output="toHtml" template="page/html/country-filter.phtml" />
    

    2b - 在您的主/父主题中创建一个模板/页面/html/country-filter.phtml 并放置可以根据您的需要更改的代码:

    if(!isset($_COOKIE['frontend'])) {
     setcookie("frontend",session_id(),time()+60*60*24,"/","");
     $ip = $_SERVER['REMOTE_ADDR'];
     $country = geoip_country_name_by_name($ip);
    
     switch($country) {
    
      case 'France':
       $url = $this->getUrl() . '?___store=YOUR_STORE_VIEW_CODE_FOR_FRANCE';
       header( 'Location:' . $url) ;
       /* (Maybe add "exit;" here)*/
       break;
    
      // (etc... for other cases)
    
      default:
       break; /* No need to specify a country/store view for default as you must have done that in System > Manage Stores in your Magento backend.*/
     }
    }
    

    【讨论】:

      【解决方案2】:

      这是一个写得很好的演练,假设您为每种语言使用单独的商店视图:

      http://fooit.blogspot.com/2009/08/auto-redirect-by-language-for-magento.html

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-03-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多