Skip to content

Commit 14f95f7

Browse files
authored
Merge pull request #9 from angryalf/patch-3
Update Translation.js
2 parents efa701e + c34aa08 commit 14f95f7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/resources/js/VueTranslation/Translation.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ export default {
44
let lang = document.documentElement.lang;
55
let word = translations[lang];
66
let fallback_locale = document.querySelector('meta[name="fallback_locale"]') || null;
7-
7+
8+
const getAltValue = (object, keys) => keys.split('.').reduce((o, k) => (o || {})[k], object);
9+
810
const keys = key.split('.');
911
for (let i in keys) {
1012
try {
1113
word = word[keys[i]];
1214
if (word === undefined) {
1315
if (fallback_locale.content){
14-
word = translations[fallback_locale.content][keys[i]];
16+
word = getAltValue(translations[fallback_locale.content], key) || key;
1517
} else {
1618
word = key;
1719
}

0 commit comments

Comments
 (0)