jQueryi18nproperties开发指南.docx

上传人:牧羊曲112 文档编号:3061460 上传时间:2023-03-10 格式:DOCX 页数:4 大小:37.54KB
返回 下载 相关 举报
jQueryi18nproperties开发指南.docx_第1页
第1页 / 共4页
jQueryi18nproperties开发指南.docx_第2页
第2页 / 共4页
jQueryi18nproperties开发指南.docx_第3页
第3页 / 共4页
jQueryi18nproperties开发指南.docx_第4页
第4页 / 共4页
亲,该文档总共4页,全部预览完了,如果喜欢就下载吧!
资源描述

《jQueryi18nproperties开发指南.docx》由会员分享,可在线阅读,更多相关《jQueryi18nproperties开发指南.docx(4页珍藏版)》请在三一办公上搜索。

1、jQueryi18nproperties开发指南jQuery.i18n.properties开发指南 jQuery.i18n.properties是jQuery的一个插件,可以通过properties文件为JavaScript提供国际化的支持。 jQuery.i18n.properties可以根据给定的Locale和国家代码的组合),加载并解析指定的properties文件,从而实现国际化。 jQuery.i18n.properties首先加载默认的properties文件,然后再加载指定Locale的properties文件。 properties文件的内容是与Locale相关的key/va

2、lue对。示例如下: Messages.properties: # This line is ignored by the plugin msg_hello = Hello msg_world = World msg_complex = Good morning 0! Messages_zh.properties: # We only provide a translation for the msg_hello key msg_hello = 你好 Messages_zh_CN.properties: # We only provide a translation for the msg_h

3、ello key msg_hello = 你好 在页面中使用jQuery.i18n.properties时,首先要应用jQuery和jQuery.i18n.properties包 其次,初始化jQuery.i18n.properties以加载properties文件如下: jQuery.i18n.properties( name:Messages, /properties文件名为Messages.properties path:bundle/, /properties文件位于本js文件的当前目录的bundle子目录下 mode:map, language:zh_CN, callback:fun

4、ction ); 补充:初始化jQuery.i18n.properties的参数列表 Option Description Notes Optional, String or String name Partial name (or names) of files representing resource bundles (eg, Messages or Msg1,Msg2). Defaults to Messages language ISO-639 Language code and, optionally, ISO-3166 country code (eg, en, en_US, z

5、h_CN). If not specified, language reported by the browser will be used instead. Optional, String path Path to directory that contains .properties files to load. Optional, String mode Option to have resource bundle keys available as Javascript vars/functions OR as a map. The map option is mandatory i

6、f your bundle keys contain Javascript Reserved Words. Possible options: vars (default), map or both. Whether bundles should be cached by the browser, or forcibly reloaded on each page load. Defaults to false (i.e. forcibly reloaded). The encoding to request for bundles. Property file resource bundle

7、s are specified to be in ISO-8859-1 format. Defaults to UTF-8 for backward compatibility. Optional, String cache Optional, boolean encoding Optional, String callback Callback function to be called upon script execution completion. Optional, function 然后就可以在页面中使用如下: / Accessing a simple value through the map jQuery.i18n.prop(msg_hello); / Accessing a value with placeholders through the map jQuery.i18n.prop(msg_complex, John); 注意:jQuery.i18n.properties的使用,必须将应用部署到服务器,通过服务器访问页面。直接通过文件系统访问页面将无法正确加载,因为浏览器存在对XMLHttpRequest跨域访问的限制。 参考文献:

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号