修复识别系统默认语言

This commit is contained in:
whyour
2026-07-04 01:13:59 +08:00
parent 38d84f9f31
commit 1953022b99
5 changed files with 25 additions and 53 deletions
+7 -2
View File
@@ -1,3 +1,5 @@
import { shareStore } from './store';
const messages: Record<string, Record<string, string>> = {
zh: {},
en: {
@@ -148,10 +150,13 @@ let currentLang: string = 'zh';
export function setLang(lang: string) {
currentLang = lang || 'zh';
shareStore.setLang(currentLang);
}
export function getLang(): string {
return currentLang;
/** 系统默认语言:Intl 检测 → 'zh'(仅返回 zh/en */
export function systemLang(): string {
const prefix = Intl.DateTimeFormat().resolvedOptions().locale.split('-')[0];
return prefix === 'en' ? 'en' : 'zh';
}
export function t(key: string, lang?: string): string {