国际化 – Jquery Mobile的i18n本地化插件?

前端之家收集整理的这篇文章主要介绍了国际化 – Jquery Mobile的i18n本地化插件?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Jquery Mobile的任何i18n本地化插件?我搜索了很多时间,但J18ery的i18n翻译插件在JQM上无法正常工作.例如在一个href ..非常感谢.

没人知道?

解决方法

我遇到了同样的问题,我只是通过使用Jquery Extend函数解决了这个问题.

假设您定义语言资源如下:

1)使用默认本地化创建资源文件,可能是用英语定义的.我们称之为resources.default.js

  1. var MyApp = MyApp || {};
  2.  
  3. MyApp.resources = {
  4. One: "One",Two: "Two",Three:"Three"
  5. }

2)在独立文件中定义本地化资源,比方说西班牙语.称之为resources.es.js

  1. var localizedResources = {
  2. One: "Uno",Two: "Dos",Three:"Tres"
  3. }

3)在您的服务器逻辑上,确定您只需要包含英语的默认翻译,或者如果您需要任何其他语言,请执行包含.

  1. <script src="resources.es.js"> </script>

4)创建您的网页,并根据步骤3添加脚本以处理您包含的资源.

  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5.  
  6. <h1>Welcome to my App</h1>
  7. <p>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​Welcome to this test app</p>
  8.  
  9. <button>Click me</button>
  10.  
  11.  
  12.  
  13. <script src="resources.default.js"> </script>
  14.  
  15.  
  16. // The server decided we needed Spanish translations.
  17. <script src="resources.es.js"> </script>
  18.  
  19.  
  20. <script type="text/javascript">
  21. //Extend the translations into the resources object.
  22.  
  23. $.extend(MyApp.resources,localizedResources);
  24.  
  25. $(window).ready(function(){
  26. $('button').click(function(){
  27. alert(MyApp.resources.One);
  28. });
  29. });
  30.  
  31. </script>
  32. </body>

这应该适合你.

编辑:
在这里看到它:http://jsfiddle.net/agarcian/rrDv3/1/

猜你在找的jQuery相关文章