i18ntk 1.10.2 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +141 -1191
  3. package/main/i18ntk-analyze.js +65 -84
  4. package/main/i18ntk-backup-class.js +420 -0
  5. package/main/i18ntk-backup.js +3 -3
  6. package/main/i18ntk-complete.js +90 -65
  7. package/main/i18ntk-doctor.js +123 -103
  8. package/main/i18ntk-fixer.js +61 -725
  9. package/main/i18ntk-go.js +14 -15
  10. package/main/i18ntk-init.js +77 -26
  11. package/main/i18ntk-java.js +27 -32
  12. package/main/i18ntk-js.js +70 -68
  13. package/main/i18ntk-manage.js +129 -30
  14. package/main/i18ntk-php.js +75 -75
  15. package/main/i18ntk-py.js +55 -56
  16. package/main/i18ntk-scanner.js +59 -57
  17. package/main/i18ntk-setup.js +9 -404
  18. package/main/i18ntk-sizing.js +6 -6
  19. package/main/i18ntk-summary.js +21 -18
  20. package/main/i18ntk-ui.js +11 -10
  21. package/main/i18ntk-usage.js +54 -18
  22. package/main/i18ntk-validate.js +13 -13
  23. package/main/manage/commands/AnalyzeCommand.js +1124 -0
  24. package/main/manage/commands/BackupCommand.js +62 -0
  25. package/main/manage/commands/CommandRouter.js +295 -0
  26. package/main/manage/commands/CompleteCommand.js +61 -0
  27. package/main/manage/commands/DoctorCommand.js +60 -0
  28. package/main/manage/commands/FixerCommand.js +624 -0
  29. package/main/manage/commands/InitCommand.js +62 -0
  30. package/main/manage/commands/ScannerCommand.js +654 -0
  31. package/main/manage/commands/SizingCommand.js +60 -0
  32. package/main/manage/commands/SummaryCommand.js +61 -0
  33. package/main/manage/commands/UsageCommand.js +60 -0
  34. package/main/manage/commands/ValidateCommand.js +978 -0
  35. package/main/manage/index-fixed.js +1447 -0
  36. package/main/manage/index.js +1462 -0
  37. package/main/manage/managers/DebugMenu.js +140 -0
  38. package/main/manage/managers/InteractiveMenu.js +177 -0
  39. package/main/manage/managers/LanguageMenu.js +62 -0
  40. package/main/manage/managers/SettingsMenu.js +53 -0
  41. package/main/manage/services/AuthenticationService.js +263 -0
  42. package/main/manage/services/ConfigurationService-fixed.js +449 -0
  43. package/main/manage/services/ConfigurationService.js +449 -0
  44. package/main/manage/services/FileManagementService.js +368 -0
  45. package/main/manage/services/FrameworkDetectionService.js +458 -0
  46. package/main/manage/services/InitService.js +1051 -0
  47. package/main/manage/services/SetupService.js +462 -0
  48. package/main/manage/services/SummaryService.js +450 -0
  49. package/main/manage/services/UsageService.js +1502 -0
  50. package/package.json +32 -29
  51. package/runtime/enhanced.d.ts +221 -221
  52. package/runtime/index.d.ts +29 -29
  53. package/runtime/index.full.d.ts +331 -331
  54. package/runtime/index.js +7 -6
  55. package/scripts/build-lite.js +17 -17
  56. package/scripts/deprecate-versions.js +23 -6
  57. package/scripts/export-translations.js +5 -5
  58. package/scripts/fix-all-i18n.js +3 -3
  59. package/scripts/fix-and-purify-i18n.js +3 -2
  60. package/scripts/fix-locale-control-chars.js +110 -0
  61. package/scripts/lint-locales.js +80 -0
  62. package/scripts/locale-optimizer.js +8 -8
  63. package/scripts/prepublish.js +21 -21
  64. package/scripts/security-check.js +117 -117
  65. package/scripts/sync-translations.js +4 -4
  66. package/scripts/sync-ui-locales.js +9 -8
  67. package/scripts/validate-all-translations.js +8 -7
  68. package/scripts/verify-deprecations.js +157 -161
  69. package/scripts/verify-translations.js +6 -5
  70. package/settings/i18ntk-config.json +282 -282
  71. package/settings/language-config.json +5 -5
  72. package/settings/settings-cli.js +9 -9
  73. package/settings/settings-manager.js +18 -18
  74. package/ui-locales/de.json +2417 -2348
  75. package/ui-locales/en.json +2415 -2352
  76. package/ui-locales/es.json +2425 -2353
  77. package/ui-locales/fr.json +2418 -2348
  78. package/ui-locales/ja.json +2463 -2361
  79. package/ui-locales/ru.json +2463 -2359
  80. package/ui-locales/zh.json +2418 -2351
  81. package/utils/admin-auth.js +2 -2
  82. package/utils/admin-cli.js +297 -297
  83. package/utils/admin-pin.js +9 -9
  84. package/utils/cli-helper.js +9 -9
  85. package/utils/config-helper.js +73 -104
  86. package/utils/config-manager.js +204 -171
  87. package/utils/config.js +5 -4
  88. package/utils/env-manager.js +249 -263
  89. package/utils/framework-detector.js +27 -24
  90. package/utils/i18n-helper.js +85 -41
  91. package/utils/init-helper.js +152 -94
  92. package/utils/json-output.js +98 -98
  93. package/utils/mini-commander.js +179 -0
  94. package/utils/missing-key-validator.js +5 -5
  95. package/utils/plugin-loader.js +40 -29
  96. package/utils/prompt.js +14 -44
  97. package/utils/safe-json.js +40 -0
  98. package/utils/secure-errors.js +3 -3
  99. package/utils/security-check-improved.js +390 -0
  100. package/utils/security-config.js +5 -5
  101. package/utils/security-fixed.js +607 -0
  102. package/utils/security.js +652 -602
  103. package/utils/setup-enforcer.js +136 -44
  104. package/utils/setup-validator.js +33 -32
  105. package/utils/ultra-performance-optimizer.js +11 -9
  106. package/utils/watch-locales.js +2 -1
  107. package/utils/prompt-fixed.js +0 -55
  108. package/utils/security-check.js +0 -454
@@ -1,332 +1,332 @@
1
- // runtime/index.full.d.ts
2
- // Complete TypeScript definitions for i18ntk runtime with encryption support
3
-
4
- export interface InitOptions {
5
- baseDir?: string;
6
- language?: string;
7
- fallbackLanguage?: string;
8
- keySeparator?: string;
9
- preload?: boolean;
10
- encryption?: {
11
- enabled?: boolean;
12
- key?: string;
13
- algorithm?: string;
14
- };
15
- cache?: {
16
- enabled?: boolean;
17
- maxSize?: number;
18
- ttl?: number;
19
- };
20
- security?: {
21
- validateInputs?: boolean;
22
- sanitizeOutput?: boolean;
23
- maxKeyLength?: number;
24
- maxValueLength?: number;
25
- };
26
- }
27
-
28
- export interface TranslateParams extends Record<string, unknown> {
29
- count?: number;
30
- context?: string;
31
- [key: string]: unknown;
32
- }
33
-
34
- export interface TranslationOptions {
35
- language?: string;
36
- fallbackLanguage?: string;
37
- namespace?: string;
38
- encryptionKey?: string;
39
- enableEncryption?: boolean;
40
- context?: string;
41
- plural?: boolean;
42
- }
43
-
44
- export interface TranslationResult<T = string> {
45
- text: T;
46
- language: string;
47
- key: string;
48
- params: TranslateParams;
49
- encrypted: boolean;
50
- metadata?: {
51
- duration: number;
52
- cacheHit: boolean;
53
- namespace?: string;
54
- };
55
- }
56
-
57
- export interface I18nRuntime {
58
- // Core translation functions
59
- translate: typeof translate;
60
- t: typeof t;
61
-
62
- // Language management
63
- setLanguage: (lang: string) => Promise<void>;
64
- getLanguage: () => string;
65
- getAvailableLanguages: () => string[];
66
- refresh: (lang?: string) => Promise<void>;
67
-
68
- // Configuration
69
- getConfig: () => Required<InitOptions>;
70
- updateConfig: (updates: Partial<InitOptions>) => Promise<void>;
71
-
72
- // Encryption utilities
73
- setEncryptionKey: (key: string) => void;
74
- getEncryptionStatus: () => boolean;
75
- encryptData: (data: string) => Promise<string>;
76
- decryptData: (encryptedData: string) => Promise<string>;
77
- generateEncryptionKey: () => string;
78
-
79
- // Validation and utilities
80
- validateTranslationKey: (key: string) => boolean;
81
- sanitizeTranslation: (text: string) => string;
82
- getTranslationMetadata: <T = string>(key: string, params?: TranslateParams, options?: TranslationOptions) => TranslationResult<T>;
83
-
84
- // Batch operations
85
- translateBatch: <T = string>(keys: string[], params?: TranslateParams[], options?: TranslationOptions) => Promise<T[]>;
86
- translateBatchEncrypted: <T = string>(keys: string[], params?: TranslateParams[], options?: TranslationOptions) => Promise<T[]>;
87
-
88
- // Namespace management
89
- addNamespace: (name: string, translations: Record<string, Record<string, string>>) => Promise<void>;
90
- removeNamespace: (name: string) => Promise<void>;
91
- getNamespace: (name: string) => Record<string, Record<string, string>> | null;
92
- listNamespaces: () => string[];
93
-
94
- // Plugin system
95
- addPlugin: (plugin: TranslationPlugin) => void;
96
- removePlugin: (name: string) => void;
97
- listPlugins: () => TranslationPlugin[];
98
-
99
- // Performance monitoring
100
- getMetrics: () => PerformanceMetrics;
101
- resetMetrics: () => void;
102
-
103
- // Event handling
104
- on: (event: TranslationEventType, handler: TranslationEventHandler) => void;
105
- off: (event: TranslationEventType, handler: TranslationEventHandler) => void;
106
- emit: (event: TranslationEventType, data: any) => void;
107
- }
108
-
109
- // Core translation functions with full TypeScript support
110
- export function translate<T = string>(
111
- key: string,
112
- params?: TranslateParams,
113
- options?: TranslationOptions
114
- ): T;
115
-
116
- export function translate<T = string>(
117
- key: string,
118
- params?: TranslateParams,
119
- options?: TranslationOptions
120
- ): Promise<T>;
121
-
122
- // Alias for translate - both i18ntk.translate and i18ntk.t are supported
123
- export const t: typeof translate;
124
-
125
- // Enhanced translation with encryption support
126
- export function translateEncrypted<T = string>(
127
- key: string,
128
- params?: TranslateParams,
129
- options?: TranslationOptions
130
- ): Promise<T>;
131
-
132
- // Type-safe translation with strict typing
133
- export function translateTyped<T = string>(
134
- key: string,
135
- params?: TranslateParams,
136
- options?: TranslationOptions
137
- ): T;
138
-
139
- // Batch translation operations
140
- export function translateBatch<T = string>(
141
- keys: string[],
142
- params?: TranslateParams[],
143
- options?: TranslationOptions
144
- ): Promise<T[]>;
145
-
146
- export function translateBatchEncrypted<T = string>(
147
- keys: string[],
148
- params?: TranslateParams[],
149
- options?: TranslationOptions
150
- ): Promise<T[]>;
151
-
152
- // Initialization function
153
- export function initRuntime(options?: InitOptions): Promise<I18nRuntime>;
154
-
155
- // Legacy initialization for backward compatibility
156
- export function initI18nRuntime(options?: InitOptions): Promise<I18nRuntime>;
157
-
158
- // Plugin system interfaces
159
- export interface TranslationPlugin {
160
- name: string;
161
- version: string;
162
- transform?: (
163
- text: string,
164
- params: TranslateParams,
165
- options: TranslationOptions
166
- ) => string;
167
- validate?: (key: string, params: TranslateParams) => boolean;
168
- encrypt?: (data: string, key: string) => Promise<string>;
169
- decrypt?: (encryptedData: string, key: string) => Promise<string>;
170
- }
171
-
172
- // Event system
173
- export type TranslationEventType =
174
- | 'translation'
175
- | 'error'
176
- | 'validation'
177
- | 'encryption'
178
- | 'cache'
179
- | 'config';
180
-
181
- export interface TranslationEvent {
182
- type: TranslationEventType;
183
- key?: string;
184
- language?: string;
185
- params?: TranslateParams;
186
- result?: string;
187
- error?: Error;
188
- timestamp: Date;
189
- duration?: number;
190
- metadata?: Record<string, unknown>;
191
- }
192
-
193
- export type TranslationEventHandler = (event: TranslationEvent) => void;
194
-
195
- // Performance monitoring
196
- export interface PerformanceMetrics {
197
- totalTranslations: number;
198
- cacheHitRate: number;
199
- averageTranslationTime: number;
200
- encryptionTime: number;
201
- memoryUsage: number;
202
- namespaceCount: number;
203
- pluginCount: number;
204
- }
205
-
206
- // Error handling
207
- export interface TranslationError extends Error {
208
- code: string;
209
- key?: string;
210
- language?: string;
211
- params?: TranslateParams;
212
- context?: string;
213
- }
214
-
215
- // Validation utilities
216
- export interface ValidationOptions {
217
- validateKey?: boolean;
218
- validateParams?: boolean;
219
- sanitizeOutput?: boolean;
220
- maxKeyLength?: number;
221
- maxValueLength?: number;
222
- }
223
-
224
- export interface ValidationResult {
225
- valid: boolean;
226
- errors: string[];
227
- warnings: string[];
228
- }
229
-
230
- // Namespace management
231
- export interface NamespaceConfig {
232
- name: string;
233
- path?: string;
234
- priority?: number;
235
- fallback?: boolean;
236
- }
237
-
238
- // Configuration builder for fluent API
239
- export class RuntimeConfigBuilder {
240
- private config: InitOptions = {};
241
-
242
- withBaseDir(dir: string): RuntimeConfigBuilder;
243
- withLanguage(lang: string): RuntimeConfigBuilder;
244
- withFallbackLanguage(lang: string): RuntimeConfigBuilder;
245
- withEncryption(key: string): RuntimeConfigBuilder;
246
- withCache(enabled: boolean, maxSize?: number, ttl?: number): RuntimeConfigBuilder;
247
- withSecurity(options: Partial<InitOptions['security']>): RuntimeConfigBuilder;
248
- withPlugin(plugin: TranslationPlugin): RuntimeConfigBuilder;
249
- withNamespace(name: string, translations: Record<string, Record<string, string>>): RuntimeConfigBuilder;
250
- build(): InitOptions;
251
- }
252
-
253
- // Type utilities for better TypeScript support
254
- export type TranslationKey<T = string> = string;
255
- export type TranslationNamespace = string;
256
- export type TranslationContext = string;
257
-
258
- export interface TranslationSchema<T = string> {
259
- [key: string]: T | TranslationSchema<T>;
260
- }
261
-
262
- export interface LanguageConfig {
263
- code: string;
264
- name: string;
265
- nativeName: string;
266
- direction: 'ltr' | 'rtl';
267
- pluralRule: (count: number) => number;
268
- dateFormat: string;
269
- numberFormat: string;
270
- fallback?: string;
271
- }
272
-
273
- // Utility types for framework integration
274
- export type I18nFunction<T = string> = (
275
- key: string,
276
- params?: TranslateParams,
277
- options?: TranslationOptions
278
- ) => T;
279
-
280
- export interface I18nContext {
281
- t: I18nFunction<string>;
282
- translate: I18nFunction<string>;
283
- language: string;
284
- setLanguage: (lang: string) => Promise<void>;
285
- }
286
-
287
- // Error codes for better error handling
288
- export const TranslationErrorCodes = {
289
- KEY_NOT_FOUND: 'I18N_KEY_NOT_FOUND',
290
- INVALID_KEY: 'I18N_INVALID_KEY',
291
- INVALID_PARAMS: 'I18N_INVALID_PARAMS',
292
- ENCRYPTION_ERROR: 'I18N_ENCRYPTION_ERROR',
293
- DECRYPTION_ERROR: 'I18N_DECRYPTION_ERROR',
294
- LANGUAGE_NOT_SUPPORTED: 'I18N_LANGUAGE_NOT_SUPPORTED',
295
- NAMESPACE_NOT_FOUND: 'I18N_NAMESPACE_NOT_FOUND',
296
- PLUGIN_ERROR: 'I18N_PLUGIN_ERROR',
297
- } as const;
298
-
299
- export type TranslationErrorCode = typeof TranslationErrorCodes[keyof typeof TranslationErrorCodes];
300
-
301
- // Constants
302
- export const SUPPORTED_LANGUAGES = [
303
- 'en', 'es', 'fr', 'de', 'ja', 'ru', 'zh', 'pt', 'it', 'ko'
304
- ] as const;
305
-
306
- export type SupportedLanguage = typeof SUPPORTED_LANGUAGES[number];
307
-
308
- // Encryption constants
309
- export const ENCRYPTION_ALGORITHMS = {
310
- AES_256_GCM: 'aes-256-gcm',
311
- AES_192_GCM: 'aes-192-gcm',
312
- AES_128_GCM: 'aes-128-gcm',
313
- } as const;
314
-
315
- export type EncryptionAlgorithm = typeof ENCRYPTION_ALGORITHMS[keyof typeof ENCRYPTION_ALGORITHMS];
316
-
317
- // Re-export existing types for backward compatibility
318
- export * from './index.d.ts';
319
-
320
- // Default export for ES modules
321
- export default {
322
- translate,
323
- t,
324
- initRuntime,
325
- initI18nRuntime,
326
- translateEncrypted,
327
- translateBatch,
328
- translateBatchEncrypted,
329
- TranslationErrorCodes,
330
- SUPPORTED_LANGUAGES,
331
- ENCRYPTION_ALGORITHMS,
1
+ // runtime/index.full.d.ts
2
+ // Complete TypeScript definitions for i18ntk runtime with encryption support
3
+
4
+ export interface InitOptions {
5
+ baseDir?: string;
6
+ language?: string;
7
+ fallbackLanguage?: string;
8
+ keySeparator?: string;
9
+ preload?: boolean;
10
+ encryption?: {
11
+ enabled?: boolean;
12
+ key?: string;
13
+ algorithm?: string;
14
+ };
15
+ cache?: {
16
+ enabled?: boolean;
17
+ maxSize?: number;
18
+ ttl?: number;
19
+ };
20
+ security?: {
21
+ validateInputs?: boolean;
22
+ sanitizeOutput?: boolean;
23
+ maxKeyLength?: number;
24
+ maxValueLength?: number;
25
+ };
26
+ }
27
+
28
+ export interface TranslateParams extends Record<string, unknown> {
29
+ count?: number;
30
+ context?: string;
31
+ [key: string]: unknown;
32
+ }
33
+
34
+ export interface TranslationOptions {
35
+ language?: string;
36
+ fallbackLanguage?: string;
37
+ namespace?: string;
38
+ encryptionKey?: string;
39
+ enableEncryption?: boolean;
40
+ context?: string;
41
+ plural?: boolean;
42
+ }
43
+
44
+ export interface TranslationResult<T = string> {
45
+ text: T;
46
+ language: string;
47
+ key: string;
48
+ params: TranslateParams;
49
+ encrypted: boolean;
50
+ metadata?: {
51
+ duration: number;
52
+ cacheHit: boolean;
53
+ namespace?: string;
54
+ };
55
+ }
56
+
57
+ export interface I18nRuntime {
58
+ // Core translation functions
59
+ translate: typeof translate;
60
+ t: typeof t;
61
+
62
+ // Language management
63
+ setLanguage: (lang: string) => Promise<void>;
64
+ getLanguage: () => string;
65
+ getAvailableLanguages: () => string[];
66
+ refresh: (lang?: string) => Promise<void>;
67
+
68
+ // Configuration
69
+ getConfig: () => Required<InitOptions>;
70
+ updateConfig: (updates: Partial<InitOptions>) => Promise<void>;
71
+
72
+ // Encryption utilities
73
+ setEncryptionKey: (key: string) => void;
74
+ getEncryptionStatus: () => boolean;
75
+ encryptData: (data: string) => Promise<string>;
76
+ decryptData: (encryptedData: string) => Promise<string>;
77
+ generateEncryptionKey: () => string;
78
+
79
+ // Validation and utilities
80
+ validateTranslationKey: (key: string) => boolean;
81
+ sanitizeTranslation: (text: string) => string;
82
+ getTranslationMetadata: <T = string>(key: string, params?: TranslateParams, options?: TranslationOptions) => TranslationResult<T>;
83
+
84
+ // Batch operations
85
+ translateBatch: <T = string>(keys: string[], params?: TranslateParams[], options?: TranslationOptions) => Promise<T[]>;
86
+ translateBatchEncrypted: <T = string>(keys: string[], params?: TranslateParams[], options?: TranslationOptions) => Promise<T[]>;
87
+
88
+ // Namespace management
89
+ addNamespace: (name: string, translations: Record<string, Record<string, string>>) => Promise<void>;
90
+ removeNamespace: (name: string) => Promise<void>;
91
+ getNamespace: (name: string) => Record<string, Record<string, string>> | null;
92
+ listNamespaces: () => string[];
93
+
94
+ // Plugin system
95
+ addPlugin: (plugin: TranslationPlugin) => void;
96
+ removePlugin: (name: string) => void;
97
+ listPlugins: () => TranslationPlugin[];
98
+
99
+ // Performance monitoring
100
+ getMetrics: () => PerformanceMetrics;
101
+ resetMetrics: () => void;
102
+
103
+ // Event handling
104
+ on: (event: TranslationEventType, handler: TranslationEventHandler) => void;
105
+ off: (event: TranslationEventType, handler: TranslationEventHandler) => void;
106
+ emit: (event: TranslationEventType, data: any) => void;
107
+ }
108
+
109
+ // Core translation functions with full TypeScript support
110
+ export function translate<T = string>(
111
+ key: string,
112
+ params?: TranslateParams,
113
+ options?: TranslationOptions
114
+ ): T;
115
+
116
+ export function translate<T = string>(
117
+ key: string,
118
+ params?: TranslateParams,
119
+ options?: TranslationOptions
120
+ ): Promise<T>;
121
+
122
+ // Alias for translate - both i18ntk.translate and i18ntk.t are supported
123
+ export const t: typeof translate;
124
+
125
+ // Enhanced translation with encryption support
126
+ export function translateEncrypted<T = string>(
127
+ key: string,
128
+ params?: TranslateParams,
129
+ options?: TranslationOptions
130
+ ): Promise<T>;
131
+
132
+ // Type-safe translation with strict typing
133
+ export function translateTyped<T = string>(
134
+ key: string,
135
+ params?: TranslateParams,
136
+ options?: TranslationOptions
137
+ ): T;
138
+
139
+ // Batch translation operations
140
+ export function translateBatch<T = string>(
141
+ keys: string[],
142
+ params?: TranslateParams[],
143
+ options?: TranslationOptions
144
+ ): Promise<T[]>;
145
+
146
+ export function translateBatchEncrypted<T = string>(
147
+ keys: string[],
148
+ params?: TranslateParams[],
149
+ options?: TranslationOptions
150
+ ): Promise<T[]>;
151
+
152
+ // Initialization function
153
+ export function initRuntime(options?: InitOptions): Promise<I18nRuntime>;
154
+
155
+ // Legacy initialization for backward compatibility
156
+ export function initI18nRuntime(options?: InitOptions): Promise<I18nRuntime>;
157
+
158
+ // Plugin system interfaces
159
+ export interface TranslationPlugin {
160
+ name: string;
161
+ version: string;
162
+ transform?: (
163
+ text: string,
164
+ params: TranslateParams,
165
+ options: TranslationOptions
166
+ ) => string;
167
+ validate?: (key: string, params: TranslateParams) => boolean;
168
+ encrypt?: (data: string, key: string) => Promise<string>;
169
+ decrypt?: (encryptedData: string, key: string) => Promise<string>;
170
+ }
171
+
172
+ // Event system
173
+ export type TranslationEventType =
174
+ | 'translation'
175
+ | 'error'
176
+ | 'validation'
177
+ | 'encryption'
178
+ | 'cache'
179
+ | 'config';
180
+
181
+ export interface TranslationEvent {
182
+ type: TranslationEventType;
183
+ key?: string;
184
+ language?: string;
185
+ params?: TranslateParams;
186
+ result?: string;
187
+ error?: Error;
188
+ timestamp: Date;
189
+ duration?: number;
190
+ metadata?: Record<string, unknown>;
191
+ }
192
+
193
+ export type TranslationEventHandler = (event: TranslationEvent) => void;
194
+
195
+ // Performance monitoring
196
+ export interface PerformanceMetrics {
197
+ totalTranslations: number;
198
+ cacheHitRate: number;
199
+ averageTranslationTime: number;
200
+ encryptionTime: number;
201
+ memoryUsage: number;
202
+ namespaceCount: number;
203
+ pluginCount: number;
204
+ }
205
+
206
+ // Error handling
207
+ export interface TranslationError extends Error {
208
+ code: string;
209
+ key?: string;
210
+ language?: string;
211
+ params?: TranslateParams;
212
+ context?: string;
213
+ }
214
+
215
+ // Validation utilities
216
+ export interface ValidationOptions {
217
+ validateKey?: boolean;
218
+ validateParams?: boolean;
219
+ sanitizeOutput?: boolean;
220
+ maxKeyLength?: number;
221
+ maxValueLength?: number;
222
+ }
223
+
224
+ export interface ValidationResult {
225
+ valid: boolean;
226
+ errors: string[];
227
+ warnings: string[];
228
+ }
229
+
230
+ // Namespace management
231
+ export interface NamespaceConfig {
232
+ name: string;
233
+ path?: string;
234
+ priority?: number;
235
+ fallback?: boolean;
236
+ }
237
+
238
+ // Configuration builder for fluent API
239
+ export class RuntimeConfigBuilder {
240
+ private config: InitOptions = {};
241
+
242
+ withBaseDir(dir: string): RuntimeConfigBuilder;
243
+ withLanguage(lang: string): RuntimeConfigBuilder;
244
+ withFallbackLanguage(lang: string): RuntimeConfigBuilder;
245
+ withEncryption(key: string): RuntimeConfigBuilder;
246
+ withCache(enabled: boolean, maxSize?: number, ttl?: number): RuntimeConfigBuilder;
247
+ withSecurity(options: Partial<InitOptions['security']>): RuntimeConfigBuilder;
248
+ withPlugin(plugin: TranslationPlugin): RuntimeConfigBuilder;
249
+ withNamespace(name: string, translations: Record<string, Record<string, string>>): RuntimeConfigBuilder;
250
+ build(): InitOptions;
251
+ }
252
+
253
+ // Type utilities for better TypeScript support
254
+ export type TranslationKey<T = string> = string;
255
+ export type TranslationNamespace = string;
256
+ export type TranslationContext = string;
257
+
258
+ export interface TranslationSchema<T = string> {
259
+ [key: string]: T | TranslationSchema<T>;
260
+ }
261
+
262
+ export interface LanguageConfig {
263
+ code: string;
264
+ name: string;
265
+ nativeName: string;
266
+ direction: 'ltr' | 'rtl';
267
+ pluralRule: (count: number) => number;
268
+ dateFormat: string;
269
+ numberFormat: string;
270
+ fallback?: string;
271
+ }
272
+
273
+ // Utility types for framework integration
274
+ export type I18nFunction<T = string> = (
275
+ key: string,
276
+ params?: TranslateParams,
277
+ options?: TranslationOptions
278
+ ) => T;
279
+
280
+ export interface I18nContext {
281
+ t: I18nFunction<string>;
282
+ translate: I18nFunction<string>;
283
+ language: string;
284
+ setLanguage: (lang: string) => Promise<void>;
285
+ }
286
+
287
+ // Error codes for better error handling
288
+ export const TranslationErrorCodes = {
289
+ KEY_NOT_FOUND: 'I18N_KEY_NOT_FOUND',
290
+ INVALID_KEY: 'I18N_INVALID_KEY',
291
+ INVALID_PARAMS: 'I18N_INVALID_PARAMS',
292
+ ENCRYPTION_ERROR: 'I18N_ENCRYPTION_ERROR',
293
+ DECRYPTION_ERROR: 'I18N_DECRYPTION_ERROR',
294
+ LANGUAGE_NOT_SUPPORTED: 'I18N_LANGUAGE_NOT_SUPPORTED',
295
+ NAMESPACE_NOT_FOUND: 'I18N_NAMESPACE_NOT_FOUND',
296
+ PLUGIN_ERROR: 'I18N_PLUGIN_ERROR',
297
+ } as const;
298
+
299
+ export type TranslationErrorCode = typeof TranslationErrorCodes[keyof typeof TranslationErrorCodes];
300
+
301
+ // Constants
302
+ export const SUPPORTED_LANGUAGES = [
303
+ 'en', 'es', 'fr', 'de', 'ja', 'ru', 'zh', 'pt', 'it', 'ko'
304
+ ] as const;
305
+
306
+ export type SupportedLanguage = typeof SUPPORTED_LANGUAGES[number];
307
+
308
+ // Encryption constants
309
+ export const ENCRYPTION_ALGORITHMS = {
310
+ AES_256_GCM: 'aes-256-gcm',
311
+ AES_192_GCM: 'aes-192-gcm',
312
+ AES_128_GCM: 'aes-128-gcm',
313
+ } as const;
314
+
315
+ export type EncryptionAlgorithm = typeof ENCRYPTION_ALGORITHMS[keyof typeof ENCRYPTION_ALGORITHMS];
316
+
317
+ // Re-export existing types for backward compatibility
318
+ export * from './index.d.ts';
319
+
320
+ // Default export for ES modules
321
+ export default {
322
+ translate,
323
+ t,
324
+ initRuntime,
325
+ initI18nRuntime,
326
+ translateEncrypted,
327
+ translateBatch,
328
+ translateBatchEncrypted,
329
+ TranslationErrorCodes,
330
+ SUPPORTED_LANGUAGES,
331
+ ENCRYPTION_ALGORITHMS,
332
332
  };