Now I'm building an app in Vue.js supports multiple Languages. And I implemented internationalization using https://kazupon.github.io/vue-i18n.
I want to change getting message part in i18n from static JSON file in a project to API call result(axios, ajax, Vuex ...etc ).
How could I get JSON message files from API server and support dynamic multi language service??
Any ideas? Thanks in advance!
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import EN from '@/COMMON/i18n/en.json'
import KO from '@/COMMON/i18n/ko.json'
import store from '@/COMMON/store/store'
Vue.use(VueI18n)
const i18n = new VueI18n({
locale: sessionStorage.LANG_CD,
fallbackLocale: 'ko',
silentTranslationWarn: true,
messages: {
en: EN,
ko: KO
// option 1. ko: axios ... some code
// option 2. ko: store.getters ... some code
},
});
export default {
i18n
}