mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
added defaultLang support, #4655
This commit is contained in:
@@ -91,6 +91,16 @@ var middleware;
|
||||
// });
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
// Build language code list
|
||||
fs.readdir(path.join(__dirname, '../public/language'), function(err, directories) {
|
||||
Plugins.languageCodes = directories.filter(function(code) {
|
||||
return code !== 'TODO';
|
||||
});
|
||||
|
||||
next();
|
||||
});
|
||||
},
|
||||
function(next) {
|
||||
db.getSortedSetRange('plugins:active', 0, -1, next);
|
||||
},
|
||||
|
||||
@@ -238,6 +238,16 @@ module.exports = function(Plugins) {
|
||||
_.extendOwn(Plugins.customLanguages[route], data);
|
||||
|
||||
if (pluginData.defaultLang && pathToLang.endsWith(pluginData.defaultLang + '/' + path.basename(pathToLang))) {
|
||||
console.log(Plugins.languageCodes);
|
||||
Plugins.languageCodes.map(function(code) {
|
||||
if (pluginData.defaultLang !== code) {
|
||||
return code + '/' + path.basename(pathToLang);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}).filter(Boolean).forEach(function(key) {
|
||||
Plugins.customLanguages[key] = _.defaults(Plugins.customLanguages[key] || {}, data);
|
||||
});
|
||||
fallbackMap[path.basename(pathToLang, '.json')] = path.join(pathToFolder, pluginData.defaultLang, path.basename(pathToLang));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user