阅读336 返回首页    go 阿里云 go 技术社区[云栖]


magento -- 隐藏国家语言列表,只保留中英文

Magento后台自身携带了一个语言切换的功能,见后台左下角

 

 

     你会发现长长的一串,其中绝大多数语言你可能根本没有机会用到,而你想要从中文切换到英文时,每次都要瞪大眼睛去找英文在下拉框的哪个位置,所以精简下还是有必要的。

以我自己的需求为例,我需要使用中文后台,偶尔会切换到英文,因为有些翻译不理想需要看下原文,那我就只保留“中文 (中国)”和“英文 (美国)”。打开根目录下/lib/Zend/Locale/Data/zh.xml文件,在大概640行找到territories标签,可以看到这个标签内部包含了一长串国家列表,把所有的territory标签全部注释掉,只提取出中国和美国

 

  <territories> <territory type="CN">中国</territory> <territory type="US">美国</territory> <!--alex <territory type="001">世界</territory> <territory type="002">非洲</territory> <territory type="003">北美洲</territory> <territory type="005">南美洲</territory> ………………………………………………………… ………………………………………………………… <territory type="ZM">赞比亚</territory> <territory type="ZW">津巴布韦</territory> <territory type="ZZ">未知或无效地区</territory> --> </territories> 

 

        清除缓存,现在,在中文状态下,后台的下拉框你将只看到这两个选项,不过当你切换为英文后下拉框又变成一长串了,所以我们还需要对/lib/Zend/Locale/Data/en.xml做相似的处理

<territories> <territory type="US">United States</territory> <territory type="CN">China</territory> <!--alex <territory type="001">World</territory> <territory type="002">Africa</territory> ……………………………………………………………… 

 

         现在试试效果,中英文切换很方便了

        

 

        同时系统基本设置里的国家列表也只剩中国和美国了,具体需要使用哪些国家各位自己配置吧。

最后更新:2017-04-02 05:21:05

  上一篇:go MyEclipse6.5上基于XFire开发Webservice
  下一篇:go magento 1.4 -- 自定义变量(Custom Variables)使用初探