Julian Lam 9 years ago
parent a63c91de3b
commit 4357c2ef4e

@ -31,6 +31,7 @@ var fs = require('fs'),
Plugins.lessFiles = [];
Plugins.clientScripts = [];
Plugins.customLanguages = [];
Plugins.customLanguageFallbacks = {};
Plugins.libraryPaths = [];
Plugins.versionWarning = [];
@ -393,12 +394,10 @@ var fs = require('fs'),
translator.addTranslation(language, filename, lang.file);
});
var fallbackPath;
for(var resource in Plugins.customLanguageFallbacks) {
fallbackPath = Plugins.customLanguageFallbacks[resource];
params.router.get('/language/:lang/' + resource + '.json', function(req, res, next) {
winston.verbose('[translator] No resource file found for ' + req.params.lang + '/' + resource + ', using provided fallback language file');
res.sendFile(fallbackPath);
winston.verbose('[translator] No resource file found for ' + req.params.lang + '/' + path.basename(req.path, '.json') + ', using provided fallback language file');
res.sendFile(Plugins.customLanguageFallbacks[path.basename(req.path, '.json')]);
});
}

@ -6,6 +6,7 @@ var fs = require('fs'),
async = require('async'),
winston = require('winston'),
nconf = require('nconf'),
_ = require('underscore'),
file = require('../file'),
utils = require('../../public/src/utils');
@ -184,7 +185,7 @@ module.exports = function(Plugins) {
route: pathToLang.replace(pathToFolder, '')
});
if (pluginData.defaultLang) {
if (pluginData.defaultLang && pathToLang.endsWith(pluginData.defaultLang + '/' + path.basename(pathToLang))) {
fallbackMap[path.basename(pathToLang, '.json')] = path.join(pathToFolder, pluginData.defaultLang, path.basename(pathToLang));
}
@ -196,7 +197,7 @@ module.exports = function(Plugins) {
}
Plugins.customLanguages = Plugins.customLanguages.concat(arr);
Plugins.customLanguageFallbacks = fallbackMap;
_.extendOwn(Plugins.customLanguageFallbacks, fallbackMap);
callback();
});

Loading…
Cancel
Save