removed for in loop

v1.18.x
barisusakli 11 years ago
parent ef4972f66b
commit fb43282a9c

@ -104,7 +104,7 @@
if (value) { if (value) {
for (var i = 1, ii = variables.length; i < ii; i++) { for (var i = 1, ii = variables.length; i < ii; i++) {
var variable = variables[i].replace(']]', ''); var variable = variables[i].replace(']]', '');
value = ('' + value).replace('%' + i, variable); value = value.replace('%' + i, variable);
} }
text = text.replace(key, value); text = text.replace(key, value);
@ -119,31 +119,35 @@
var keys = data.match(/\[\[.*?\]\]/g), var keys = data.match(/\[\[.*?\]\]/g),
loading = 0; loading = 0;
for (var key in keys) { if (!keys) {
if (keys.hasOwnProperty(key)) { return callback(data);
keys[key] = '' + keys[key]; }
var variables = keys[key].split(/[,][?\s+]/);
var parsedKey = keys[key].replace('[[', '').replace(']]', '').split(':'); for (var i=0; i<keys.length; ++i) {
if (!(parsedKey[0] && parsedKey[1])) { var key = keys[i];
continue;
}
var languageFile = parsedKey[0]; key = '' + key;
parsedKey = ('' + parsedKey[1]).split(',')[0]; var variables = key.split(/[,][?\s+]/);
if (files.loaded[languageFile]) { var parsedKey = key.replace('[[', '').replace(']]', '').split(':');
data = insertLanguage(data, keys[key], files.loaded[languageFile][parsedKey], variables); if (!(parsedKey[0] && parsedKey[1])) {
} else { continue;
loading++; }
(function (languageKey, parsedKey, languageFile, variables) {
translator.load(languageFile, function (languageData) { var languageFile = parsedKey[0];
data = insertLanguage(data, languageKey, languageData[parsedKey], variables); parsedKey = ('' + parsedKey[1]).split(',')[0];
loading--;
checkComplete(); if (files.loaded[languageFile]) {
}); data = insertLanguage(data, key, files.loaded[languageFile][parsedKey], variables);
}(keys[key], parsedKey, languageFile, variables)); } else {
} loading++;
(function (languageKey, parsedKey, languageFile, variables) {
translator.load(languageFile, function (languageData) {
data = insertLanguage(data, languageKey, languageData[parsedKey], variables);
loading--;
checkComplete();
});
}(key, parsedKey, languageFile, variables));
} }
} }
@ -154,7 +158,6 @@
callback(data); callback(data);
} }
} }
}; };
translator.clearLoadedFiles = function() { translator.clearLoadedFiles = function() {

Loading…
Cancel
Save