refactor: 移除英文翻译,仅保留中文

删除 public/_locales/en/ 目录,清理 chromeI18n.ts 中未使用的语言切换相关导出。

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
雨霖铃
2026-05-28 19:27:15 +08:00
parent 8b6bac9f2c
commit 1daf049737
3 changed files with 4 additions and 1319 deletions
File diff suppressed because it is too large Load Diff
+1 -22
View File
@@ -18,27 +18,6 @@ export function getMessage(msgId: string, substitutions?: string[]): string {
}
}
/**
* 获取当前浏览器语言
* @returns 语言代码(如 'zh', 'en'
*/
export function getLanguage(): string {
const lang = chrome.i18n.getUILanguage();
return lang.toLowerCase().startsWith('zh') ? 'zh' : 'en';
}
/**
* 支持的语言列表
*/
export const SUPPORTED_LANGUAGES: readonly ('zh' | 'en')[] = ['zh', 'en'] as const;
/**
* 规范化语言代码
*/
export function normalizeLanguage(lng: string): 'zh' | 'en' {
return lng.toLowerCase().startsWith('zh') ? 'zh' : 'en';
}
/**
* react-i18next 兼容的 Hook
* 返回 t 函数和相关信息
@@ -82,7 +61,7 @@ export function useI18n(namespace?: string | string[]) {
return {
t,
i18n: {
language: getLanguage(),
language: 'zh',
changeLanguage: (_lng?: string) => {
// chrome.i18n 无法动态切换语言,需要刷新页面
console.warn('[chrome.i18n] 无法动态切换语言,需要刷新页面');
+2 -6
View File
@@ -3,11 +3,9 @@ import { afterEach, beforeEach, vi } from 'vitest';
import React from 'react';
// Load actual zh translations for getMessage mock
const zhMessages: Record<string, { message: string }> =
// eslint-disable-next-line @typescript-eslint/no-require-imports
const zhMessages: Record<
string,
{ message: string }
> = require('./public/_locales/zh/messages.json');
require('./public/_locales/zh/messages.json');
vi.mock('@/utils/chromeI18n', () => ({
useI18n: (ns?: string | string[]) => ({
@@ -37,8 +35,6 @@ vi.mock('@/utils/chromeI18n', () => ({
}),
getMessage: (msgId: string) => zhMessages[msgId]?.message ?? msgId,
getLanguage: () => 'zh',
normalizeLanguage: (lng: string) => (lng.startsWith('zh') ? 'zh' : 'en'),
SUPPORTED_LANGUAGES: ['zh', 'en'],
preloadNamespaces: vi.fn().mockResolvedValue(undefined),
}));