Reputation: 378
I'm trying to expand the already loaded localizations for a specific component and I would like to do something like this:
export default {
name: 'General',
components: {
Header,
Content,
NextPageButton
},
i18n: {
messages: {
[this.$i18n.locale]: { message: require('@/locales/' + this.$i18n.locale + '/tso/general.json') }
}
}
Problem is of course that the $i18n is undefined inside the i18n options. How can I retrieve the current locale here?
Upvotes: 2
Views: 4909
Reputation: 1006
I use the Vue instance like: this.Vue.$i18n.locale
Another way of access is this.$root.$i18n.locale
Upvotes: 2