XVoxel-ASync/lib/locales.js

33 lines
1018 B
JavaScript

module.exports = {
"languages": {},
"loadFromJSON": function (language, data) {
if (!(language in module.exports.languages)) module.exports.languages[language] = {};
for (var dat in data) {
if (data.hasOwnProperty(dat)) {
module.exports.languages[language][dat] = data[dat];
}
}
},
"getRawString": function (language, stringName) {
if (!(language in module.exports.languages)) return;
if (!(stringName in module.exports.languages[language])) return;
return module.exports.languages[language][stringName];
},
"getFormattedString": function (language, stringName, variables) {
if (!(language in module.exports.languages)) return;
if (!(stringName in module.exports.languages[language])) return;
var formattedString = module.exports.languages[language][stringName];
for (var variable in variables) {
if (variables.hasOwnProperty(variable)) {
formattedString = formattedString.replaceAll("${" + variable + "}", variables[variable]);
}
}
return formattedString;
}
};