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

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

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

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

[xhtml] view plaincopy
  1. <territories>  
  2.         <territory type="CN">中国</territory>  
  3.         <territory type="US">美国</territory>  
  4.         <!--alex   
  5.             <territory type="001">世界</territory>  
  6.             <territory type="002">非洲</territory>  
  7.             <territory type="003">北美洲</territory>  
  8.             <territory type="005">南美洲</territory>  
  9.               …………………………………………………………  
  10.                   …………………………………………………………  
  11.             <territory type="ZM">赞比亚</territory>  
  12.             <territory type="ZW">津巴布韦</territory>  
  13.             <territory type="ZZ">未知或无效地区</territory>  
  14.             -->  
  15.         </territories>  

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

[xhtml] view plaincopy
  1. <territories>  
  2.         <territory type="US">United States</territory>  
  3.         <territory type="CN">China</territory>  
  4.         <!--alex   
  5.             <territory type="001">World</territory>  
  6.             <territory type="002">Africa</territory>  
  7.             ………………………………………………………………  

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

        

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

原文地址:https://www.cnblogs.com/zhouwenwu/p/2475183.html