@ui18n/angular
Version:
🅰️ Modern Angular internationalization with standalone components, signals, and dependency injection support for Angular 15+
189 lines • 6.7 kB
TypeScript
/**
* ui18n 核心包入口文件
* 导出所有公共API
*/
export { UI18n, createUI18n } from './ui18n';
export * from './api-config';
export * from './fallback-manager';
export * from './translation-providers';
export * from './secure-config';
export { escapeHtml, sanitizeInput, interpolateSafely, detectXSS, SecurityManager, raw, RawHTML, isRawHTML, type SecurityConfig } from './security';
export type { UI18nConfig, SupportedLanguage, AIProvider, AIProviderConfig, CacheConfig, TranslationResult, TranslationRequest, DictionaryEntry, LanguageDetectionResult, TranslationSearchResult, EnterpriseUI18nConfig, TranslationStats, SystemStatus, ServiceMode, DeveloperStats, LanguagePackStatus, StatsQuery } from './types';
import type { UI18nConfig, SupportedLanguage, AIProvider } from './types';
import { UI18n } from './ui18n';
export { LanguageDetector } from './language-detector';
export { BuiltinDictionary } from './builtin-dictionary';
export { CacheManager } from './cache-manager';
export { AITranslator } from './ai-translator';
export { normalizeLocale } from './locale-utils';
export { ServiceModeManager } from './service-mode';
export { TranslationPipeline } from './translation-pipeline';
export { VersionControlManager } from './version-control';
export { DeveloperStatsService, DefaultCostCalculator, defaultStatsService, type StatsDataPoint, type CostCalculator } from './developer-stats-service';
export { PhraseLibraryManager, defaultPhraseLibrary, type PhraseEntry, type PhraseLibraryConfig, type MatchResult, type PhraseLibraryStats } from './phrase-library';
export { IncrementalTranslationManager, defaultIncrementalManager, type TranslationFileStatus, type ChangeRecord, type SyncStatus, type ConflictResolution, type IncrementalSyncConfig } from './incremental-translation';
export declare const VERSION = "0.1.0";
export declare const DEFAULT_CONFIG: Partial<UI18nConfig>;
/**
* 快速创建UI18n实例的便捷函数
* @param apiKey AI服务的API密钥
* @param provider AI提供商类型,默认为'openai'
* @param options 其他配置选项
* @returns UI18n实例
*/
export declare function quickSetup(apiKey?: string, provider?: AIProvider, options?: Partial<UI18nConfig>): UI18n;
/**
* 检查浏览器环境支持情况
* @returns 支持情况报告
*/
export declare function checkBrowserSupport(): {
localStorage: boolean;
fetch: boolean;
intl: boolean;
overall: boolean;
};
/**
* 获取推荐的语言列表(基于用户地区)
* @returns 推荐的语言数组
*/
export declare function getRecommendedLanguages(): SupportedLanguage[];
/**
* 创建企业级UI18n实例(启用所有高级功能)
* @param config 企业级配置
* @returns UI18n实例
*/
export declare function createEnterpriseUI18n(config: {
apiKey: string;
provider?: AIProvider;
serviceMode?: 'self-hosted' | 'cloud' | 'hybrid';
enableVersionControl?: boolean;
}): UI18n;
/**
* 创建开发环境UI18n实例(适合开发和测试)
* @param apiKey AI服务API密钥
* @param provider AI提供商
* @returns UI18n实例
*/
export declare function createDevelopmentUI18n(apiKey?: string, provider?: AIProvider): UI18n;
/**
* 创建生产环境UI18n实例(性能优化)
* @param config 生产环境配置
* @returns UI18n实例
*/
export declare function createProductionUI18n(config: {
apiKey: string;
provider?: AIProvider;
enableVersionControl?: boolean;
}): UI18n;
/**
* 创建多语言切换器的辅助函数
* @param ui18n UI18n实例
* @param languages 支持的语言列表
* @returns 语言切换器对象
*/
export declare function createLanguageSwitcher(ui18n: UI18n, languages: SupportedLanguage[]): {
/**
* 获取当前语言
*/
getCurrentLanguage(): SupportedLanguage;
/**
* 切换语言
*/
switchLanguage(language: SupportedLanguage): void;
/**
* 获取支持的语言列表
*/
getSupportedLanguages(): SupportedLanguage[];
/**
* 获取语言显示名称
*/
getLanguageDisplayName(language: SupportedLanguage): string;
/**
* 检查是否支持某种语言
*/
isLanguageSupported(language: SupportedLanguage): boolean;
};
/**
* 创建翻译监控器,用于监控翻译性能和成本
* @param ui18n UI18n实例
* @returns 监控器对象
*/
export declare function createTranslationMonitor(ui18n: UI18n): {
/**
* 获取系统状态
*/
getSystemStatus(): {
currentLanguage: string;
serviceMode: "self-hosted" | "cloud" | "hybrid";
serviceModeStats: import("./service-mode").ServiceModeStats;
cacheStats: import("./cache-manager").CacheStats;
builtinStats: {
totalKeys: number;
supportedLanguages: SupportedLanguage[];
coverage: Record<SupportedLanguage, number>;
};
translationPipelineStats: import("./translation-pipeline").PipelineStats;
versionControlStats: import("./version-control").VersionControlStats | undefined;
supportedLanguages: string[];
};
/**
* 获取成本统计
*/
getCostStats(): {
totalRequests: number;
batchedRequests: number;
mergedRequests: number;
costSavings: number;
batchingEfficiency: number;
} | undefined;
/**
* 获取缓存统计
*/
getCacheStats(): import("./cache-manager").CacheStats;
/**
* 获取翻译管道统计
*/
getTranslationStats(): import("./translation-pipeline").PipelineStats;
/**
* 获取批量处理状态
*/
getBatchStatus(): {
currentOptimalBatchSize: number;
pendingBatches: number;
activeBatches: number;
mergingBuffer: number;
totalRequests: number;
batchedRequests: number;
mergedRequests: number;
costSavings: number;
averageBatchSize: number;
batchingEfficiency: number;
} | undefined;
/**
* 检查是否需要同步
*/
checkForUpdates(): Promise<Map<any, any>>;
/**
* 创建性能报告
*/
createPerformanceReport(): {
timestamp: string;
performance: {
cacheHitRate: number;
averageResponseTime: number;
totalTranslations: number;
};
cost: {
dailySpent: number;
monthlySpent: number;
dailyBudgetUsage: number;
monthlyBudgetUsage: number;
};
system: {
serviceMode: "self-hosted" | "cloud" | "hybrid";
queueSize: number;
isProcessing: boolean;
};
};
};
//# sourceMappingURL=index.d.ts.map