mirror of
https://github.com/node-red/node-red.git
synced 2023-10-10 13:36:53 +02:00
switched loading order
This commit is contained in:
parent
4d6828ec14
commit
683c6a748e
19
packages/node_modules/@node-red/util/lib/i18n.js
vendored
19
packages/node_modules/@node-red/util/lib/i18n.js
vendored
@ -118,19 +118,12 @@ var MessageFileLoader = {
|
||||
type: "backend",
|
||||
init: function (services, backendOptions, i18nextOptions) { },
|
||||
read: function (lng, ns, callback) {
|
||||
// there are two languages to consider:
|
||||
// 1) the actual language lng (e. g. 'en-US' or 'de-DE', 'fr-FR',...)
|
||||
// 2) the base language (e. g. 'en', 'de', 'fr',...)
|
||||
var baseLng = lng.split('-')[0];
|
||||
// read base language (e. g. 'de'), then actual language (e. g. 'de-DE')
|
||||
readFile(baseLng, ns).then(
|
||||
baseData => {
|
||||
// scenario 1: reading base language was successful -> read actual language -> if this fails, return base language data
|
||||
readFile(lng, ns).then(data => callback(null, data), () => callback(null, baseData))
|
||||
},
|
||||
() => {
|
||||
// scenario 2: reading base language failed -> read actual language -> if this fails too, return error
|
||||
readFile(lng, ns).then(data => callback(null, data), err => callback(err))
|
||||
readFile(lng, ns)
|
||||
.then(data => callback(null, data))
|
||||
.catch(() => {
|
||||
// if reading language file fails -> try reading base language (e. g. 'fr' instead of 'fr-FR' or 'de' for 'de-DE')
|
||||
var baseLng = lng.split('-')[0];
|
||||
readFile(baseLng, ns).then(baseData => callback(null, baseData)).catch(err => callback(err));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user