Spaces:
Runtime error
Runtime error
File size: 385 Bytes
56b6519 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
var fs = require('fs');
var gLocale = 'en';
function setLocale(locale) {
gLocale = locale;
}
exports.setLocale = setLocale;
function translate(message, locale = gLocale) {
try {
let dictionary = JSON.parse(fs.readFileSync(`${__dirname}/${locale}.json`));
return dictionary[message] || message;
} catch (error) {
return message;
}
}
exports.translate = translate;
|