|
|
|
@ -265,6 +265,7 @@
|
|
|
|
|
path = require('path'),
|
|
|
|
|
winston = require('winston'),
|
|
|
|
|
file = require('../../../src/file'),
|
|
|
|
|
plugins = require('../../../src/plugins'),
|
|
|
|
|
meta = require('../../../src/meta');
|
|
|
|
|
|
|
|
|
|
language = language || meta.config.defaultLang || 'en_GB';
|
|
|
|
@ -275,11 +276,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fs.readFile(path.join(__dirname, '../../language', language, filename + '.json'), function(err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|
winston.error('Could not load `' + filename + '`: ' + err.message + '. Skipping...');
|
|
|
|
|
return callback({});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var onData = function(data) {
|
|
|
|
|
try {
|
|
|
|
|
data = JSON.parse(data.toString());
|
|
|
|
|
} catch (e) {
|
|
|
|
@ -287,6 +284,27 @@
|
|
|
|
|
data = {};
|
|
|
|
|
}
|
|
|
|
|
callback(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
if (err.code === 'ENOENT' && plugins.customLanguageFallbacks.hasOwnProperty(filename)) {
|
|
|
|
|
// Resource non-existant but fallback exists
|
|
|
|
|
return fs.readFile(plugins.customLanguageFallbacks[filename], {
|
|
|
|
|
encoding: 'utf-8'
|
|
|
|
|
}, function(err, data) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return winston.error('[translator] Could not load fallback language file for resource ' + filename);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onData(data);
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
winston.error('[translator] Could not load `' + filename + '`: ' + err.message + '. Skipping...');
|
|
|
|
|
return callback({});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onData(data);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|