zoukankan      html  css  js  c++  java
  • I18n国际化

    JS获取国际化文件:
        1:loadTWProperties() 加载 common_zh-TW.properties 文件,
        2:$.i18n.prop('user') 获取文件中的值

    function loadTWProperties(){
      jQuery.i18n.properties({
    	name:'common',        //文件名
    	path:'jscipt/i18n/',  //路径
    	language : 'zh-TW',   //后缀 
    	mode:'map'
      });
    }
    function loadCNProperties(){
      jQuery.i18n.properties({
    	name:'common',        //文件名
    	path:'jscipt/i18n/',  //路径
    	language : 'zh-CN',   //后缀 
    	mode:'map'
      });
    }

    JSP获取国际化文件:

       1:jsp顶部加入<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
       2:basename文件名
         <fmt:bundle basename="messagerResources"> 
          <fmt:message key="user"/>  
         </fmt:bundle>
    

      

     JAVA获取国际化文件:applicationContext.xml加入bean

      <!-- 资源文件绑定器 -->
      <bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
    	  <!-- <property name="basename" value="messagerResources" /> -->
    	  <property name="basenames">
    	  	<list>
    			<value>messagerResources</value>
    		</list>
    	  </property>
      </bean>
    
      private static ApplicationContext ctx = new FileSystemXmlApplicationContext("classpath:applicationContext.xml");
      String strCHINA= ctx.getMessage(key,args,Locale.CHINA)   //获取中文
      String strENGLISH= ctx.getMessage(key,args,Locale.ENGLISH); //获取英文
    

      

      

  • 相关阅读:
    iframe的边框如何去掉
    vue-computed计算属性用法
    Vue-input框checkbox强制刷新
    TED 积极心理学感悟(二)
    路由器使用子网掩码进行分组转发的过程
    DHCP 服务器和 DHCP 客户端的交互过程
    IPv4 协议中的 NAT 协议和 CIDR 协议
    IPv6 是解决 IPv4 地址耗尽问题的根本途径
    TED 积极心理学感悟
    初级错误之 for 中的局部变量
  • 原文地址:https://www.cnblogs.com/zhoucx66/p/8066055.html
Copyright © 2011-2022 走看看