Fix #790: editor breaking when missing some translations
This commit is contained in:
parent
259b32d441
commit
b3c0eedc08
|
@ -3,6 +3,11 @@
|
|||
https://github.com/josdejong/jsoneditor
|
||||
|
||||
|
||||
## not yet published, version 8.2.1
|
||||
|
||||
- Fix #790: editor breaking when missing some translations.
|
||||
|
||||
|
||||
## 2020-01-16, version 8.2.0
|
||||
|
||||
- Make it easy to create custom styling by overriding default SASS variable
|
||||
|
|
|
@ -575,12 +575,12 @@ export function setLanguages (languages) {
|
|||
if (!languages) {
|
||||
return
|
||||
}
|
||||
for (const key in languages) {
|
||||
const langFound = _locales.find(l => l === key)
|
||||
for (const language in languages) {
|
||||
const langFound = _locales.find(l => l === language)
|
||||
if (!langFound) {
|
||||
_locales.push(key)
|
||||
_locales.push(language)
|
||||
}
|
||||
_defs[key] = Object.assign({}, _defs[_defaultLang], _defs[key], languages[key])
|
||||
_defs[language] = Object.assign({}, _defs[_defaultLang], _defs[language], languages[language])
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -588,11 +588,11 @@ export function translate (key, data, lang) {
|
|||
if (!lang) {
|
||||
lang = _lang
|
||||
}
|
||||
let text = _defs[lang][key]
|
||||
let text = _defs[lang][key] || _defs[_defaultLang][key] || key
|
||||
if (data) {
|
||||
for (key in data) {
|
||||
text = text.replace('${' + key + '}', data[key])
|
||||
for (const dataKey in data) {
|
||||
text = text.replace('${' + dataKey + '}', data[dataKey])
|
||||
}
|
||||
}
|
||||
return text || key
|
||||
return text
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue