- Reorganize project structure with new electron and shared directories - Add comprehensive i18n support with Chinese, English, and Japanese locales - Update build configurations and TypeScript paths for new structure - Add various UI components including chat interface and task management - Include Windows release binaries and localization files - Update dependencies and fix import paths throughout the codebase
37 lines
950 B
TypeScript
37 lines
950 B
TypeScript
import { CONFIG_KEYS } from '@lib/constants'
|
|
import logManager from '@electron/service/logger'
|
|
import configManager from '@electron/service/config-service'
|
|
import path from 'node:path'
|
|
|
|
import en from '@locales/en.json'
|
|
import zh from '@locales/zh.json'
|
|
|
|
type MessageSchema = typeof zh;
|
|
const messages: Record<string, MessageSchema> = { en, zh }
|
|
|
|
export function createTranslator() {
|
|
return (key?: string) => {
|
|
if (!key) return void 0;
|
|
try {
|
|
const keys = key?.split('.');
|
|
let result: any = messages[configManager.get(CONFIG_KEYS.LANGUAGE)];
|
|
for (const _key of keys) {
|
|
result = result[_key];
|
|
}
|
|
return result as string;
|
|
} catch (e) {
|
|
logManager.error('failed to translate key:', key, e);
|
|
return key
|
|
}
|
|
}
|
|
}
|
|
|
|
let logo: string | void = void 0;
|
|
export function createLogo() {
|
|
if (logo != null) {
|
|
return logo;
|
|
}
|
|
logo = path.join(__dirname, '/public/logo.ico');
|
|
return logo;
|
|
}
|