feat: 实现 C 端移动溯源页(响应式 H5 + 中英 i18n)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import zhCN from './zh-CN.json';
|
||||
import enUS from './en-US.json';
|
||||
|
||||
const KEY = 'artveris_h5_locale';
|
||||
|
||||
export function getInitialLocale(): string {
|
||||
const saved = localStorage.getItem(KEY);
|
||||
if (saved) return saved;
|
||||
return navigator.language.startsWith('en') ? 'en-US' : 'zh-CN';
|
||||
}
|
||||
|
||||
export const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: getInitialLocale(),
|
||||
fallbackLocale: 'zh-CN',
|
||||
messages: { 'zh-CN': zhCN, 'en-US': enUS },
|
||||
});
|
||||
|
||||
export function setLocale(l: string): void {
|
||||
localStorage.setItem(KEY, l);
|
||||
i18n.global.locale.value = l as 'zh-CN' | 'en-US';
|
||||
}
|
||||
Reference in New Issue
Block a user