Cordys HTML5 多语言代码 解读
来源:互联网 发布:如何进入it行业 知乎 编辑:程序博客网 时间:2024/06/07 14:24
Cordys 多语言设计思路
<label for="inputName" data-translatable="true">User Name</label>
如果页面上需要翻译 则添加自定义标签。 data-translatable='true' 则可以利用JQuery 找到所有的对象$("data-translatable='true'")
var selector = "[data-translatable='true']"; $(selector).each(function () {var $this = $(this);var label_name=$this.text().trim();//得到label name,然后利用label name去匹配,把对应的值找出来。$this.text(getMessage($this.text().trim())); }
//利用Ajax读取本地文件 $.ajax({type: "GET",url: "translation/html5sdk/sdkmessagebundle_zh-CN.xml",async: true,cache: true,success : function(response){res=response;}});
//将本地文件转为Json数组$.cordys.json.xml2js(res)//找到某个对象dictionary=$.cordys.json.find($.cordys.json.xml2js(res), "dictionary");//var self = this;this.path = path;this.dictionary = dictionary;this.getMessage = function () {var id = arguments[0],label = null,ttext = "";if (self.dictionary) {label = $.cordys.json.find(self.dictionary, "@textidentifier", id);}ttext = label ? (label[language] ? (label[language].text || label[language]) : id) : id;if (arguments.length > 1) {var args = Array.prototype.slice.call(arguments).slice(1);ttext = ttext.replace(/\{(\d+)\}/g, function () {return typeof(args[arguments[1]]) !== "undefined" ? args[arguments[1]] : arguments[0];});}return ttext;}
0 0
- Cordys HTML5 多语言代码 解读
- Cordys 设置 多语言
- Cordys HTML5 SDK BootStrap
- cordys HTML5 SSO 开发注意点
- Java 代码获取Cordys令牌,获取Cordys相应WebService数据
- [解读]html5游戏app_Sinuous
- 代码解读
- 代码解读
- 基于Cordys BOP 4 维护开发代码实践经验
- html5多文件上传代码
- Cordys学习心得
- Cordys-XPath
- Cordys-LDAP
- cordys Xpath
- 语言的深度解读
- 解读女性语言
- 解读男性语言
- 转:SRILM语言解读
- 判断字符串为空的方法
- Cgroup框架分析
- 复选框(checkbox)和单选框(radio)与文字居中对齐
- 如何面对客户的紧急需求
- 学习windows驱动(框架和IO请求)
- Cordys HTML5 多语言代码 解读
- Android Thinkandroid学习之 http请求
- 深入JVM系列(二)之GC机制、收集器与GC调优
- quick-cocos2dx之特效按钮——缩放按钮
- 【objective-c】面试题和基本概念
- hbase多master
- 位图的应用
- MTK 平台 CAMERA 驱动浅析
- 关于扩大按钮响应区域的方法