大佬教程收集整理的这篇文章主要介绍了国际化 – Jquery Mobile的i18n本地化插件?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
假设您定义语言资源如下:
1)使用默认本地化创建资源文件,可能是用英语定义的.我们称之为resources.default.js
var MyApp = MyApp || {}; MyApp.resources = { One: "One",Two: "Two",Three:"Three" }
2)在独立文件中定义本地化资源,比方说西班牙语.称之为resources.es.js
var localizedresources = { One: "Uno",Two: "Dos",Three:"Tres" }
3)在您的服务器逻辑上,确定您只需要包含英语的默认翻译,或者如果您需要任何其他语言,请执行包含.
<script src="resources.es.js"> </script>
4)创建您的网页,并根据步骤3添加脚本以处理您包含的资源.
<html> <head> </head> <body> <h1>Welcome to my App</h1> <p>Welcome to this test app</p> <button>Click me</button> <script src="resources.default.js"> </script> // The server decided we needed Spanish translations. <script src="resources.es.js"> </script> <script type="text/javascript"> //Extend the translations into the resources object. $.extend(MyApp.resources,localizedresources); $(window).ready(function(){ $('button').click(function(){ alert(MyApp.resources.OnE); }); }); </script> </body>
这应该适合你.
以上是大佬教程为你收集整理的国际化 – Jquery Mobile的i18n本地化插件?全部内容,希望文章能够帮你解决国际化 – Jquery Mobile的i18n本地化插件?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。