added defaultLang support, #4655

v1.18.x
Julian Lam 9 years ago
parent 437770538c
commit ffa051e828

@ -91,6 +91,16 @@ var middleware;
// }); // });
async.waterfall([ 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) { function(next) {
db.getSortedSetRange('plugins:active', 0, -1, next); db.getSortedSetRange('plugins:active', 0, -1, next);
}, },

@ -238,6 +238,16 @@ module.exports = function(Plugins) {
_.extendOwn(Plugins.customLanguages[route], data); _.extendOwn(Plugins.customLanguages[route], data);
if (pluginData.defaultLang && pathToLang.endsWith(pluginData.defaultLang + '/' + path.basename(pathToLang))) { 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)); fallbackMap[path.basename(pathToLang, '.json')] = path.join(pathToFolder, pluginData.defaultLang, path.basename(pathToLang));
} }

Loading…
Cancel
Save