UNPKG

@ui18n/cli

Version:

🌍 UI18n CLI工具 - 强大的国际化命令行工具

213 lines 4.38 kB
/** * CLI工具的类型定义 */ /** * 日志级别 */ export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'silent'; /** * 日志选项 */ export interface LogOptions { level: LogLevel; colors: boolean; timestamp: boolean; logFile?: string; } /** * 命令选项 */ export interface CommandOptions { [key: string]: any; } /** * 命令定义 */ export interface Command { name: string; description: string; options?: CommandOption[]; action: (options: CommandOptions, ...args: string[]) => Promise<void> | void; } /** * 命令选项定义 */ export interface CommandOption { flags: string; description: string; defaultValue?: any; } /** * CLI配置 */ export interface CLIConfig { logLevel: LogLevel; colors: boolean; timestamp: boolean; interactive: boolean; backup: boolean; } /** * UI18n配置 */ export interface UI18nConfig { defaultLanguage: string; fallbackLanguage: string; supportedLanguages: string[]; sourceDir: string; outputDir: string; include: string[]; exclude?: string[]; extractOptions?: { markers: string[]; keyStyle: 'flat' | 'nested'; sort: boolean; removeUnused: boolean; }; translateOptions?: { batchSize: number; concurrency: number; retryCount: number; retryDelay: number; }; cache?: { enabled: boolean; type: 'memory' | 'file' | 'redis'; maxSize: number; ttl: number; }; aiProvider?: { type: 'openai' | 'anthropic' | 'custom'; apiKey: string; endpoint?: string; model?: string; timeout?: number; }; } /** * 文本提取结果 */ export interface ExtractResult { file: string; texts: ExtractedText[]; } /** * 提取的文本 */ export interface ExtractedText { key: string; text: string; line: number; column: number; context?: string; } /** * 翻译结果 */ export interface TranslationResult { language: string; translations: Record<string, string>; errors: TranslationError[]; } /** * 翻译错误 */ export interface TranslationError { key: string; text: string; error: string; } /** * 统计信息 */ export interface Statistics { totalFiles: number; totalTexts: number; translatedTexts: number; languages: string[]; cacheHitRate: number; processingTime: number; } /** * 初始化选项 */ export interface InitOptions { framework?: 'react' | 'vue' | 'angular' | 'svelte'; typescript?: boolean; defaultLanguage?: string; supportedLanguages?: string[]; aiProvider?: string; interactive?: boolean; } /** * 提取选项 */ export interface ExtractOptions { patterns?: string[]; output?: string; format?: 'json' | 'yaml' | 'csv'; sort?: boolean; removeUnused?: boolean; dryRun?: boolean; } /** * 翻译选项 */ export interface TranslateOptions { languages?: string[]; force?: boolean; batchSize?: number; concurrency?: number; dryRun?: boolean; output?: string; } /** * 配置选项 */ export interface ConfigOptions { set?: string; get?: string; list?: boolean; reset?: boolean; } /** * 统计选项 */ export interface StatsOptions { format?: 'table' | 'json' | 'csv'; output?: string; detailed?: boolean; } /** * 进度回调 */ export type ProgressCallback = (current: number, total: number, message?: string) => void; /** * 错误处理器 */ export type ErrorHandler = (error: Error, context?: any) => void; /** * 插件接口 */ export interface Plugin { name: string; version: string; init: (cli: any) => void | Promise<void>; } /** * 中间件函数 */ export type Middleware = (context: any, next: () => Promise<void>) => Promise<void>; /** * 钩子函数 */ export interface Hooks { beforeInit?: () => void | Promise<void>; afterInit?: () => void | Promise<void>; beforeExtract?: (files: string[]) => void | Promise<void>; afterExtract?: (results: ExtractResult[]) => void | Promise<void>; beforeTranslate?: (texts: string[], language: string) => void | Promise<void>; afterTranslate?: (results: TranslationResult) => void | Promise<void>; onError?: ErrorHandler; } //# sourceMappingURL=types.d.ts.map