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

      

      

  • 相关阅读:
    SpringBoot入门
    VUE 监听局部滚动 设置ICON的位置跟随
    手机端页面调试工具-vconsole使用
    js获取字符串字节的位数
    判断数据为[] {} /空数组或空对象
    Vue axios 上传图片
    Vue触发input选取文件点击事件
    腾讯地图添加多个Marker
    VUE-CLI 设置页面title
    小程序wxml文件引用方式
  • 原文地址:https://www.cnblogs.com/zhoucx66/p/8066055.html
Copyright © 2020-2023  润新知