微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

Jquery Mobile的任何i18n本地化插件?我搜索了很多时间,但J18ery的i18n翻译插件在JQM上无法正常工作.例如在一个href ..非常感谢.

没人知道?

解决方法

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

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

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>

这应该适合你.

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

原文地址:https://www.jb51.cc/jquery/177383.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐