只读模式
group, 分享
评论更多问题
博客标签总是存在一个
This commit is contained in:
lealife
2015-06-15 18:01:48 +08:00
parent 7e458bb433
commit 6987a38820
1453 changed files with 114561 additions and 91536 deletions

53
public/tinymce/classes/util/I18n.js Normal file → Executable file
View File

@ -17,14 +17,36 @@
define("tinymce/util/I18n", [], function() {
"use strict";
var data = {};
var data = {}, code = "en";
return {
/**
* Sets the current language code.
*
* @method setCode
* @param {String} newCode Current language code.
*/
setCode: function(newCode) {
if (newCode) {
code = newCode;
this.rtl = this.data[newCode] ? this.data[newCode]._dir === 'rtl' : false;
}
},
/**
* Returns the current language code.
*
* @return {String} Current language code.
*/
getCode: function() {
return code;
},
/**
* Property gets set to true if a RTL language pack was loaded.
*
* @property rtl
* @type {Boolean}
* @type Boolean
*/
rtl: false,
@ -36,11 +58,17 @@ define("tinymce/util/I18n", [], function() {
* @param {Array} items Name/value array with English en_US to sv_SE.
*/
add: function(code, items) {
for (var name in items) {
data[name] = items[name];
var langData = data[code];
if (!langData) {
data[code] = langData = {};
}
this.rtl = this.rtl || data._dir === 'rtl';
for (var name in items) {
langData[name] = items[name];
}
this.setCode(code);
},
/**
@ -56,23 +84,30 @@ define("tinymce/util/I18n", [], function() {
* @return {String} String that got translated.
*/
translate: function(text) {
if (typeof(text) == "undefined") {
var langData;
langData = data[code];
if (!langData) {
langData = {};
}
if (typeof text == "undefined") {
return text;
}
if (typeof(text) != "string" && text.raw) {
if (typeof text != "string" && text.raw) {
return text.raw;
}
if (text.push) {
var values = text.slice(1);
text = (data[text[0]] || text[0]).replace(/\{([^\}]+)\}/g, function(match1, match2) {
text = (langData[text[0]] || text[0]).replace(/\{([0-9]+)\}/g, function(match1, match2) {
return values[match2];
});
}
return data[text] || text;
return (langData[text] || text).replace(/{context:\w+}$/, '');
},
data: data