mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
work-in-progress commit for #4655
This commit is contained in:
@@ -219,26 +219,23 @@ module.exports = function(Plugins) {
|
||||
fallbackMap = {};
|
||||
|
||||
utils.walk(pathToFolder, function(err, languages) {
|
||||
var arr = [];
|
||||
|
||||
async.each(languages, function(pathToLang, next) {
|
||||
fs.readFile(pathToLang, function(err, file) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
var json;
|
||||
var data;
|
||||
var route = pathToLang.replace(pathToFolder + '/', '');
|
||||
|
||||
try {
|
||||
json = JSON.parse(file.toString());
|
||||
data = JSON.parse(file.toString());
|
||||
} catch (err) {
|
||||
winston.error('[plugins] Unable to parse custom language file: ' + pathToLang + '\r\n' + err.stack);
|
||||
return next(err);
|
||||
}
|
||||
|
||||
arr.push({
|
||||
file: json,
|
||||
route: pathToLang.replace(pathToFolder, '')
|
||||
});
|
||||
Plugins.customLanguages[route] = Plugins.customLanguages[route] || {};
|
||||
_.extendOwn(Plugins.customLanguages[route], data);
|
||||
|
||||
if (pluginData.defaultLang && pathToLang.endsWith(pluginData.defaultLang + '/' + path.basename(pathToLang))) {
|
||||
fallbackMap[path.basename(pathToLang, '.json')] = path.join(pathToFolder, pluginData.defaultLang, path.basename(pathToLang));
|
||||
@@ -251,7 +248,7 @@ module.exports = function(Plugins) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
Plugins.customLanguages = Plugins.customLanguages.concat(arr);
|
||||
// do I need this either?
|
||||
_.extendOwn(Plugins.customLanguageFallbacks, fallbackMap);
|
||||
|
||||
callback();
|
||||
|
||||
Reference in New Issue
Block a user