Files
AIGC/demo/frontend/src/locales/index.js
2025-11-13 17:01:39 +08:00

24 lines
642 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { createI18n } from 'vue-i18n'
import zh from './zh'
import en from './en'
// 从localStorage获取保存的语言设置默认中文
const savedLanguage = localStorage.getItem('language') || 'zh'
console.log('[i18n] 从 localStorage 读取的语言:', savedLanguage)
console.log('[i18n] 可用的语言:', Object.keys({ zh, en }))
const i18n = createI18n({
legacy: false, // 使用Composition API模式
locale: savedLanguage, // 默认语言
fallbackLocale: 'zh', // 回退语言
messages: {
zh,
en
}
})
console.log('[i18n] i18n 初始化完成,当前语言:', i18n.global.locale.value)
export default i18n