'Show key as localization | Vue i18n
Is there any solution to display the keys as localization?
I red in the documentation that I can create decision maps for fallbackLocale and my approach was to define a decision for default -> en and a decision for 'not-a-language' -> ''.
new VueI18n({
locale,
fallbackLocale: {
'not-a-language': '',
default: 'en'
},
messages
})
In an event listener I set the current language to an not existing one.
i18n.locale = 'not-a-language'
But instead of showing the key, it shows the english translation.
Solution 1:[1]
Why is this happening
When using a fallback decision map like in your case, the default decision map will always be used after the decision map for your specific locale. So the fallback chain would be: 'not-a-language' > '' > 'en'
You can find more information here: https://kazupon.github.io/vue-i18n/guide/fallback.html#explicit-fallback-with-decision-maps
How to display keys
As far as I know there is no built-in way to do this specifically. But changing the locale to '' seems to do the trick.
i18n.locale = ''
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | DominicB |