1
0
Fork 0

fix(i18n): Add optional chaining

This commit is contained in:
joostdecock 2021-09-04 13:20:42 +02:00
parent d53bb8e6fb
commit d7f6613345

View file

@ -86,15 +86,14 @@ for (let pattern of Object.keys(patterns)) {
if (typeof value === 'object') options[pattern][option] = value
else {
if (typeof value === 'undefined') {
if (typeof patterns[shared[pattern].dflt][option] === 'object')
if (typeof patterns?.[shared?.[pattern]?.dflt]?.[option] === 'object')
options[pattern][option] = patterns[shared[pattern].dflt][option]
else if (
typeof shared[pattern].other !== 'undefined' &&
typeof shared[pattern].other[option] === 'string'
typeof shared?.[pattern]?.other !== 'undefined' &&
typeof shared?.[pattern]?.other?.[option] === 'string'
)
options[pattern][option] = patterns[shared[pattern].other[option]][option]
else {
console.log(options[pattern])
throw new Error(`No option translation found for ${option} in ${pattern}`)
}
}