prevent translator crash if data is undefined; linted/cleanup

v1.18.x
psychobunny 11 years ago
parent cd336006fc
commit 6e8c618fb1

@ -1,13 +1,10 @@
(function (module) { (function (module) {
"use strict"; "use strict";
/*global RELATIVE_PATH*/ /*global RELATIVE_PATH, config*/
/* /*
* TODO: * TODO:
* * user side settings for preferred language
* 1. recursion needed when parsing language keys (ex. topics:modal.delete.title), right now json is all one level deep
* 2. user side settings for preferred language
*
*/ */
var translator = {}, var translator = {},
@ -98,8 +95,9 @@
}; };
translator.translate = function (data, callback) { translator.translate = function (data, callback) {
var keys = data.match(/\[\[.*?\]\]/g), if (!data) {
loading = 0; return callback(data);
}
function insertLanguage(text, key, value, variables) { function insertLanguage(text, key, value, variables) {
if (value) { if (value) {
@ -117,6 +115,9 @@
return text; return text;
} }
var keys = data.match(/\[\[.*?\]\]/g),
loading = 0;
for (var key in keys) { for (var key in keys) {
if (keys.hasOwnProperty(key)) { if (keys.hasOwnProperty(key)) {
keys[key] = '' + keys[key]; keys[key] = '' + keys[key];

Loading…
Cancel
Save