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
e88b4a4412
commit
604ba7f4bc
@ -16,30 +16,12 @@
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
var i18n;
|
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){
|
function determineLangFromHeaders(acceptedLanguages){
|
||||||
var lang = i18n.defaultLang;
|
var lang = i18n.defaultLang;
|
||||||
acceptedLanguages = acceptedLanguages || [];
|
acceptedLanguages = acceptedLanguages || [];
|
||||||
for (var i=0;i<acceptedLanguages.length;i++){
|
if (acceptedLanguages.length >= 1) {
|
||||||
if (supportedLangs.indexOf(acceptedLanguages[i]) !== -1){
|
lang = acceptedLanguages[0];
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return lang;
|
return lang;
|
||||||
}
|
}
|
||||||
@ -47,7 +29,6 @@ function determineLangFromHeaders(acceptedLanguages){
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
init: function(runtime) {
|
init: function(runtime) {
|
||||||
i18n = runtime.i18n;
|
i18n = runtime.i18n;
|
||||||
initSupportedLangs();
|
|
||||||
},
|
},
|
||||||
get: function(req,res) {
|
get: function(req,res) {
|
||||||
var namespace = req.params[0];
|
var namespace = req.params[0];
|
||||||
|
Loading…
Reference in New Issue
Block a user