mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
Allow nodes to have translations not in core (#1183)
* Allow nodes to have translations not in core Currently only languages in the core are checked when the editor requests a translation. This means that if a node includes more translations they are not checked. This change removes the check against that short list, but it only checks the first language from the browser suported list * remove whitespace
This commit is contained in:
parent
a82926dd0d
commit
a5d9e17a8c
@ -16,30 +16,12 @@
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var i18n;
|
||||
var supportedLangs = [];
|
||||
|
||||
var apiLocalDir = path.resolve(path.join(__dirname,"locales"));
|
||||
|
||||
var initSupportedLangs = function() {
|
||||
fs.readdir(apiLocalDir, function(err,files) {
|
||||
if(!err) {
|
||||
supportedLangs = files;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function determineLangFromHeaders(acceptedLanguages){
|
||||
var lang = i18n.defaultLang;
|
||||
acceptedLanguages = acceptedLanguages || [];
|
||||
for (var i=0;i<acceptedLanguages.length;i++){
|
||||
if (supportedLangs.indexOf(acceptedLanguages[i]) !== -1){
|
||||
lang = acceptedLanguages[i];
|
||||
break;
|
||||
// check the language without the country code
|
||||
} else if (supportedLangs.indexOf(acceptedLanguages[i].split("-")[0]) !== -1) {
|
||||
lang = acceptedLanguages[i].split("-")[0];
|
||||
break;
|
||||
}
|
||||
if (acceptedLanguages.length >= 1) {
|
||||
lang = acceptedLanguages[0];
|
||||
}
|
||||
return lang;
|
||||
}
|
||||
@ -47,7 +29,6 @@ function determineLangFromHeaders(acceptedLanguages){
|
||||
module.exports = {
|
||||
init: function(runtime) {
|
||||
i18n = runtime.i18n;
|
||||
initSupportedLangs();
|
||||
},
|
||||
get: function(req,res) {
|
||||
var namespace = req.params[0];
|
||||
|
Loading…
Reference in New Issue
Block a user