码迷,mamicode.com
首页 > 其他好文 > 详细

I18n国际化

时间:2017-12-19 19:46:06      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:htm   query   ati   efi   property   gpo   lap   源文件   文件名   

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

  

  

I18n国际化

标签:htm   query   ati   efi   property   gpo   lap   源文件   文件名   

原文地址:http://www.cnblogs.com/zhoucx66/p/8066055.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!