适用于Jquery Mobile的i18n本地化插件?

red*_*rom 7 internationalization jquery-mobile

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

没人知道?

aga*_*ian 3

我也遇到了同样的问题,我简单地使用 Jquery Extend 函数解决了该问题。

\n\n

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

\n\n

1) 创建一个具有默认本地化的资源文件,大概是用英语定义的。我们称之为 resources.default.js

\n\n
var MyApp = MyApp || {};\n\nMyApp.resources = {\n    One: "One",\n    Two: "Two",\n    Three:"Three"    \n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n\n
var localizedResources = {\n    One: "Uno",\n    Two: "Dos",\n    Three:"Tres"    \n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

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

\n\n
<script src="resources.es.js"> </script> \n
Run Code Online (Sandbox Code Playgroud)\n\n

4) 按照步骤 3 创建网页,并添加脚本来处理资源包含情况。

\n\n
<html>\n<head>\n</head>\n<body>\n\n\xe2\x80\x8b<h1>Welcome to my App</h1>\n<p>\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8b\xe2\x80\x8bWelcome to this test app</p>\n\n<button>Click me</button>\xe2\x80\x8b\n\n\n\n<script src="resources.default.js"> </script> \n\n\n// The server decided we needed Spanish translations.\n<script src="resources.es.js"> </script> \n\n\n<script type="text/javascript">\n    //Extend the translations into the resources object.\n\n    $.extend(MyApp.resources, localizedResources);\n\n    $(window).ready(function(){\n        $(\'button\').click(function(){\n            alert(MyApp.resources.One);    \n        });    \n    });\n\n</script>  \n</body>\n
Run Code Online (Sandbox Code Playgroud)\n\n

这应该适合您。\n\xe2\x80\x8b\n编辑:\n在此处查看它的实际效果: http ://jsfiddle.net/agarcian/rrDv3/1/

\n