现在我正在 Vue.js 中构建一个支持多种语言的应用程序。我使用https://kazupon.github.io/vue-i18n实现了国际化。
我想将 i18n 中的获取消息部分从项目中的静态 JSON 文件更改为 API 调用结果(axios、ajax、Vuex ...等)。
如何从 API 服务器获取 JSON 消息文件并支持动态多语言服务?
有任何想法吗?提前致谢!
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
}
Run Code Online (Sandbox Code Playgroud) 在 java、javascript 和 c# 的循环中使用注释是否存在任何性能问题?我不认为这会是个问题,但我想知道你是如何工作的。
/*
Case 1
This is Loop for something.
a : ace
b : bee
*/
for (i=0; i<100000; i++) {
/*
Case 2
This is Loop for something.
a : ace
b : bee
*/
var a = "1";
var b = "2";
}
Run Code Online (Sandbox Code Playgroud)