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); //获取英文
    

      

      

  • 相关阅读:
    12/21
    和寶寶在一起3/10
    11/23
    c#windows应用程序窗体间传值
    用OWC做统计图
    javascript 创建字典
    .NetCom双向数据交换的实现(RecordSet与.Net DataSet的转化)
    JScript 方法 indexOf 方法
    详尽解析window.event对象
    Window.Open详解
  • 原文地址:https://www.cnblogs.com/zhoucx66/p/8066055.html
Copyright © 2011-2022 走看看