Files
Cli-Proxy-API-Management-Ce…/src/utils/constants.ts
T
fc9b8e2d40 feat(i18n): add Vietnamese (vi) locale (#382)
Add a complete Vietnamese translation for the Management Center UI:

- src/i18n/locales/vi.json: full translation of all 1540 keys from
  en.json, with all interpolation placeholders preserved
- src/i18n/index.ts: register the vi resource bundle
- src/types/common.ts: extend the Language type with 'vi'
- src/utils/constants.ts: add 'vi' to LANGUAGE_ORDER and
  LANGUAGE_LABEL_KEYS
- src/utils/language.ts: auto-detect vi-* browser languages
- locales/{en,zh-CN,zh-TW,ru}.json: add the Tiếng Việt label so the
  new language appears in every language switcher

Tested by building with vite and deploying the bundle against a live
CLIProxyAPI v7.2.133 server; vi-* browsers resolve to the Vietnamese
UI and all strings render with correct placeholders.

Co-authored-by: nguyenha935 <nguyenha935@users.noreply.github.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-05 03:01:41 +08:00

49 lines
1.6 KiB
TypeScript

/**
* 常量定义
* 从原项目 src/utils/constants.js 迁移
*/
import type { Language } from '@/types';
const defineLanguageOrder = <T extends readonly Language[]>(
languages: T & ([Language] extends [T[number]] ? unknown : never)
) => languages;
// 缓存过期时间(毫秒)
export const CACHE_EXPIRY_MS = 30 * 1000; // 与基线保持一致,减少管理端压力
// 网络与版本信息
export const DEFAULT_API_PORT = 8317;
export const MANAGEMENT_API_PREFIX = '/v8/management';
export const REQUEST_TIMEOUT_MS = 30 * 1000;
export const CPA_VERSION_HEADER_KEYS = ['x-cpa-version'];
export const CPA_BUILD_DATE_HEADER_KEYS = ['x-cpa-build-date'];
export const CPA_SUPPORT_PLUGIN_HEADER_KEYS = ['x-cpa-support-plugin'];
export const VERSION_HEADER_KEYS = [...CPA_VERSION_HEADER_KEYS, 'x-server-version'];
export const BUILD_DATE_HEADER_KEYS = [...CPA_BUILD_DATE_HEADER_KEYS, 'x-server-build-date'];
// 日志相关
export const LOGS_TIMEOUT_MS = 60 * 1000;
// 认证文件分页
export const MAX_AUTH_FILE_SIZE = 10 * 1024 * 1024;
// 本地存储键名
export const STORAGE_KEY_AUTH = 'cli-proxy-auth';
export const STORAGE_KEY_THEME = 'cli-proxy-theme';
export const STORAGE_KEY_LANGUAGE = 'cli-proxy-language';
// 语言配置
export const LANGUAGE_ORDER = defineLanguageOrder(['zh-CN', 'zh-TW', 'en', 'ru', 'vi'] as const);
export const LANGUAGE_LABEL_KEYS: Record<Language, string> = {
'zh-CN': 'language.chinese',
'zh-TW': 'language.chinese_tw',
en: 'language.english',
ru: 'language.russian',
vi: 'language.vietnamese',
};
export const SUPPORTED_LANGUAGES = LANGUAGE_ORDER;
// 通知持续时间
export const NOTIFICATION_DURATION_MS = 3000;