Vue i18n - 如何在 i18n 组件选项中获取当前语言环境?
Vue i18n - How do I get the current locale inside the i18n component options?
我正在尝试为特定组件扩展已加载的本地化,我想做这样的事情:
export default {
name: 'General',
components: {
Header,
Content,
NextPageButton
},
i18n: {
messages: {
[this.$i18n.locale]: { message: require('@/locales/' + this.$i18n.locale + '/tso/general.json') }
}
}
问题当然是 $i18n 在 i18n 选项中未定义。如何在此处检索当前语言环境?
我像这样使用 Vue 实例:this.Vue.$i18n.locale
另一种访问方式是this.$root.$i18n.locale
我正在尝试为特定组件扩展已加载的本地化,我想做这样的事情:
export default {
name: 'General',
components: {
Header,
Content,
NextPageButton
},
i18n: {
messages: {
[this.$i18n.locale]: { message: require('@/locales/' + this.$i18n.locale + '/tso/general.json') }
}
}
问题当然是 $i18n 在 i18n 选项中未定义。如何在此处检索当前语言环境?
我像这样使用 Vue 实例:this.Vue.$i18n.locale
另一种访问方式是this.$root.$i18n.locale