feat: 后台语言包合并默认中文、日夜主题切换、官方侧栏收缩、追溯码分组与批量
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,22 +1,20 @@
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import zhCommon from './zh-CN/common.json';
|
||||
import zhMenu from './zh-CN/menu.json';
|
||||
import zhPages from './zh-CN/pages.json';
|
||||
import enCommon from './en-US/common.json';
|
||||
import enMenu from './en-US/menu.json';
|
||||
import enPages from './en-US/pages.json';
|
||||
import zhCN from './zh-CN.json';
|
||||
import enUS from './en-US.json';
|
||||
|
||||
// 新增语言:在本目录添加 <locale>.json(与 zh-CN.json 同构),并在此注册即可。
|
||||
export const SUPPORTED_LOCALES = [
|
||||
{ value: 'zh-CN', label: '中文' },
|
||||
{ value: 'en-US', label: 'English' },
|
||||
];
|
||||
|
||||
const STORAGE_KEY = 'artveris_locale';
|
||||
const DEFAULT_LOCALE = 'zh-CN';
|
||||
|
||||
export function getInitialLocale(): string {
|
||||
const saved = localStorage.getItem(STORAGE_KEY);
|
||||
if (saved && SUPPORTED_LOCALES.some((l) => l.value === saved)) return saved;
|
||||
return navigator.language.startsWith('en') ? 'en-US' : 'zh-CN';
|
||||
return DEFAULT_LOCALE;
|
||||
}
|
||||
|
||||
export function setLocale(locale: string): void {
|
||||
@@ -28,9 +26,9 @@ export function setLocale(locale: string): void {
|
||||
export const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: getInitialLocale(),
|
||||
fallbackLocale: 'zh-CN',
|
||||
fallbackLocale: DEFAULT_LOCALE,
|
||||
messages: {
|
||||
'zh-CN': { common: zhCommon, menu: zhMenu, pages: zhPages },
|
||||
'en-US': { common: enCommon, menu: enMenu, pages: enPages },
|
||||
'zh-CN': zhCN,
|
||||
'en-US': enUS,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user