Files
zn-ai/src-react/i18n/resolver.ts
duanshuwen b1dea9a5c2 feat: implement task management store with IPC integration
- Added a new task store in `src-react/stores/task.ts` to manage tasks and their statuses.
- Implemented functions for creating, executing, and retrying tasks, along with handling task progress and completion.
- Introduced persistence for tasks using IPC.
- Created utility functions for normalizing room types and building subtasks.
- Added a new CSS file for global styles in `src-react/styles.css`.
- Created runtime types in `src-react/types/runtime.ts` and exported them.
- Updated the main entry points for Vue and React applications to support dynamic framework loading.
- Refactored chat model interfaces and utility functions into `src/shared/chat-model.ts`.
- Updated TypeScript configuration to include paths for React components and types.
- Enhanced Vite configuration to support both Vue and React frameworks.
2026-04-17 07:09:56 +08:00

25 lines
874 B
TypeScript

import { SUPPORTED_LANGUAGE_CODES } from './constants';
import type { LanguageCode } from '../types/runtime';
const SUPPORTED_LANGUAGE_SET = new Set<string>(SUPPORTED_LANGUAGE_CODES);
export function normalizeLocale(locale: string | null | undefined): string {
return locale?.trim().toLowerCase().split('_').join('-') ?? '';
}
export function resolveSupportedLanguage(
locale: string | null | undefined,
fallback: LanguageCode = 'zh',
): LanguageCode {
const normalizedLocale = normalizeLocale(locale);
if (!normalizedLocale) return fallback;
const [baseLanguage] = normalizedLocale.split('-');
return SUPPORTED_LANGUAGE_SET.has(baseLanguage) ? (baseLanguage as LanguageCode) : fallback;
}
export function detectSystemLanguage(): LanguageCode {
if (typeof navigator === 'undefined') return 'zh';
return resolveSupportedLanguage(navigator.language);
}