We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am using the vue framework, and now my i18n directory is like this
The index.js file is used to set the global language. The code is below
`import Vue from "vue"; import VueI18n from "vue-i18n";
Vue.use(VueI18n);
function getMessages(modules, languages) { let messages = {}; languages.forEach(lang => { messages[lang] = {}; });
modules.forEach(moduleName => { languages.forEach(async lang => { try { let { default: obj } = await import("./" + ${moduleName}/${lang}.json); // { en: { base: { } }, zh: { base: {} }} !messages[lang][moduleName] && (messages[lang][moduleName] = {}); Object.assign(messages[lang][moduleName], obj); } catch (e) { console.warn(e.message); } }); }); console.log(messages); return messages; }
${moduleName}/${lang}.json
const modules = ["base", "studyPayment"]; // 模块数组 const languages = ["en", "zh"]; // 语言数组 let messages = getMessages(modules, languages);
const i18n = new VueI18n({ locale: localStorage.getItem("lang") || "zh", // 设置默认语言环境 messages });
// 设置Element语言 ELEMENT.locale(ELEMENT.lang[localStorage.getItem("lang") || "zh"]);
export default i18n;`
I want to use i18n-ally. What configuration do I need? I have tried many times but it doesn't work.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I am using the vue framework, and now my i18n directory is like this
The index.js file is used to set the global language. The code is below
`import Vue from "vue";
import VueI18n from "vue-i18n";
Vue.use(VueI18n);
function getMessages(modules, languages) {
let messages = {};
languages.forEach(lang => {
messages[lang] = {};
});
modules.forEach(moduleName => {
languages.forEach(async lang => {
try {
let { default: obj } = await import("./" +
${moduleName}/${lang}.json
);// { en: { base: { } }, zh: { base: {} }}
!messages[lang][moduleName] && (messages[lang][moduleName] = {});
Object.assign(messages[lang][moduleName], obj);
} catch (e) {
console.warn(e.message);
}
});
});
console.log(messages);
return messages;
}
const modules = ["base", "studyPayment"]; // 模块数组
const languages = ["en", "zh"]; // 语言数组
let messages = getMessages(modules, languages);
const i18n = new VueI18n({
locale: localStorage.getItem("lang") || "zh", // 设置默认语言环境
messages
});
// 设置Element语言
ELEMENT.locale(ELEMENT.lang[localStorage.getItem("lang") || "zh"]);
export default i18n;`
I want to use i18n-ally. What configuration do I need? I have tried many times but it doesn't work.
The text was updated successfully, but these errors were encountered: