i18ntk 1.10.2 → 2.0.3

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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18ntk",
3
- "version": "1.10.2",
3
+ "version": "2.0.3",
4
4
  "description": "🚀 The fastest i18n toolkit with 97% performance boost! Zero-dependency, enterprise-grade internationalization for React, Vue, Angular, Python, Java, PHP & more. Features PIN protection, auto framework detection, 7+ UI languages, and comprehensive translation management. Perfect for startups to enterprises.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -116,10 +116,10 @@
116
116
  "url": "https://github.com/vladnoskv"
117
117
  },
118
118
  "type": "commonjs",
119
- "main": "main/i18ntk-manage.js",
119
+ "main": "main/manage/index.js",
120
120
  "types": "runtime/i18ntk.d.ts",
121
121
  "exports": {
122
- ".": "./main/i18ntk-manage.js",
122
+ ".": "./main/manage/index.js",
123
123
  "./runtime": {
124
124
  "types": "./runtime/i18ntk.d.ts",
125
125
  "require": "./runtime/index.js",
@@ -139,9 +139,9 @@
139
139
  "./package.json": "./package.json"
140
140
  },
141
141
  "bin": {
142
- "i18ntk": "main/i18ntk-manage.js",
142
+ "i18ntk": "main/manage/index.js",
143
143
  "i18ntk-setup": "main/i18ntk-setup.js",
144
- "i18ntk-manage": "main/i18ntk-manage.js",
144
+ "i18ntk-manage": "main/manage/index.js",
145
145
  "i18ntk-init": "main/i18ntk-init.js",
146
146
  "i18ntk-analyze": "main/i18ntk-analyze.js",
147
147
  "i18ntk-validate": "main/i18ntk-validate.js",
@@ -150,9 +150,9 @@
150
150
  "i18ntk-sizing": "main/i18ntk-sizing.js",
151
151
  "i18ntk-summary": "main/i18ntk-summary.js",
152
152
  "i18ntk-doctor": "main/i18ntk-doctor.js",
153
- "i18ntk-fixer": "./main/i18ntk-fixer.js",
154
- "i18ntk-scanner": "./main/i18ntk-scanner.js",
155
- "i18ntk-backup": "./main/i18ntk-backup.js"
153
+ "i18ntk-fixer": "main/i18ntk-fixer.js",
154
+ "i18ntk-scanner": "main/i18ntk-scanner.js",
155
+ "i18ntk-backup": "main/i18ntk-backup.js"
156
156
  },
157
157
  "directories": {
158
158
  "doc": "docs",
@@ -171,9 +171,9 @@
171
171
  ],
172
172
  "sideEffects": false,
173
173
  "scripts": {
174
- "i18ntk": "node main/i18ntk-manage.js",
174
+ "i18ntk": "node main/manage/index.js",
175
175
  "i18ntk-setup": "node main/i18ntk-setup.js",
176
- "i18ntk-manage": "node main/i18ntk-manage.js",
176
+ "i18ntk-manage": "node main/manage/index.js",
177
177
  "i18ntk-init": "node main/i18ntk-init.js",
178
178
  "i18ntk-analyze": "node main/i18ntk-analyze.js",
179
179
  "i18ntk-validate": "node main/i18ntk-validate.js",
@@ -190,8 +190,14 @@
190
190
  "i18ntk-java": "node main/i18ntk-java.js",
191
191
  "i18ntk-php": "node main/i18ntk-php.js",
192
192
  "i18ntk-go": "node main/i18ntk-go.js",
193
- "start": "node main/i18ntk-manage.js",
194
- "security:check": "node utils/security-check.js",
193
+ "start": "node main/manage/index.js",
194
+ "security:check": "node utils/security-check-improved.js",
195
+ "security:test": "node --test tests/security.test.js",
196
+ "security:audit": "npm run security:check && npm run security:test",
197
+ "test": "npm run security:test",
198
+ "test:all": "npm run security:audit",
199
+ "prepublishOnly": "npm run security:audit",
200
+ "prepare": "npm run security:check",
195
201
  "backup:create": "node main/i18ntk-backup.js create",
196
202
  "backup:restore": "node main/i18ntk-backup.js restore",
197
203
  "backup:list": "node main/i18ntk-backup.js list",
@@ -200,6 +206,7 @@
200
206
  "languages:select": "node settings/settings-cli.js",
201
207
  "languages:list": "node settings/settings-cli.js --list-languages",
202
208
  "languages:status": "node settings/settings-cli.js --language-status",
209
+ "lint:locales": "node scripts/lint-locales.js",
203
210
  "deprecate:versions": "node scripts/deprecate-versions.js",
204
211
  "deprecate:dry-run": "node scripts/deprecate-versions.js --dry-run",
205
212
  "deprecate:verify": "node scripts/verify-deprecations.js"
@@ -213,26 +220,20 @@
213
220
  },
214
221
  "preferGlobal": true,
215
222
  "versionInfo": {
216
- "version": "1.10.2",
217
- "releaseDate": "23/08/2025",
218
- "lastUpdated": "23/08/2025",
223
+ "version": "2.0.0",
224
+ "releaseDate": "01/01/2026",
225
+ "lastUpdated": "11/04/2026",
219
226
  "maintainer": "Vladimir Noskov",
220
227
  "changelog": "./CHANGELOG.md",
221
228
  "documentation": "./README.md",
222
229
  "apiReference": "./docs/api/API_REFERENCE.md",
223
230
  "majorChanges": [
224
- "SECURITY: Complete removal of child_process dependencies - zero shell access",
225
- "FEATURE: Python framework support (Django, Flask, FastAPI)",
226
- "PERFORMANCE: 97% faster processing (15.38ms for 200k keys)",
227
- "FEATURE: Enhanced framework detection with 95% accuracy",
228
- "ENHANCEMENT: Multi-language support with 8 built-in UI languages",
229
- "FEATURE: Interactive translation fixer with custom placeholders",
230
- "SECURITY: PIN protection and encrypted configuration storage",
231
- "OPTIMIZATION: Memory usage <2MB for any operation",
232
- "FEATURE: Comprehensive backup and recovery system",
233
- "BUGFIX: Windows path resolution improvements",
234
- "DOCUMENTATION: Updated for v1.10.1 with Python support",
235
- "MAINTENANCE: Clean package structure - 2.2 MB total size"
231
+ "BREAKING: Unified v2 command surface and release metadata",
232
+ "SECURITY: Zero runtime dependencies and hardened config IO",
233
+ "I18N: Added missing translation keys used by init/fixer/sizing/summary/usage/settings flows",
234
+ "RELIABILITY: Initialization detection now honors .i18ntk-config setup state",
235
+ "RELIABILITY: Added async safeReadFile/safeWriteFile + safeParseJSON compatibility helpers",
236
+ "INIT: Auto-bootstrap source locale file when source language directory is empty"
236
237
  ],
237
238
  "breakingChanges": [],
238
239
  "deprecations": [
@@ -258,9 +259,11 @@
258
259
  "1.8.2",
259
260
  "1.8.3",
260
261
  "1.9.0",
261
- "1.10.1"
262
+ "1.10.1",
263
+ "1.10.2",
264
+ "1.10.3"
262
265
  ],
263
- "nextVersion": "1.11.0",
266
+ "nextVersion": "2.1.0",
264
267
  "supportedNodeVersions": ">=16.0.0",
265
268
  "supportedFrameworks": {
266
269
  "react-i18next": ">=11.0.0",
@@ -1,222 +1,222 @@
1
- // runtime/enhanced.d.ts
2
- // Enhanced runtime API with TypeScript support and AES-256-GCM encryption
3
-
4
- export interface TranslationParams extends Record<string, unknown> {
5
- count?: number;
6
- context?: string;
7
- [key: string]: unknown;
8
- }
9
-
10
- export interface TranslationOptions {
11
- language?: string;
12
- fallbackLanguage?: string;
13
- namespace?: string;
14
- encryptionKey?: string;
15
- enableEncryption?: boolean;
16
- }
17
-
18
- export interface TranslationResult {
19
- text: string;
20
- language: string;
21
- key: string;
22
- params: TranslationParams;
23
- encrypted: boolean;
24
- }
25
-
26
- export interface I18nConfig {
27
- baseDir: string;
28
- defaultLanguage: string;
29
- fallbackLanguage: string;
30
- keySeparator: string;
31
- preload: boolean;
32
- encryption: {
33
- enabled: boolean;
34
- algorithm: string;
35
- keyLength: number;
36
- ivLength: number;
37
- authTagLength: number;
38
- };
39
- cache: {
40
- enabled: boolean;
41
- maxSize: number;
42
- ttl: number;
43
- };
44
- security: {
45
- validateInputs: boolean;
46
- sanitizeOutput: boolean;
47
- maxKeyLength: number;
48
- maxValueLength: number;
49
- };
50
- }
51
-
52
- export interface TranslationKey<T = string> {
53
- key: string;
54
- defaultValue?: T;
55
- description?: string;
56
- context?: string;
57
- plural?: boolean;
58
- }
59
-
60
- export interface PluralizationRule {
61
- rule: (count: number) => number;
62
- examples: string[];
63
- }
64
-
65
- export interface LanguageConfig {
66
- code: string;
67
- name: string;
68
- direction: 'ltr' | 'rtl';
69
- pluralRules: PluralizationRule;
70
- dateFormat: string;
71
- numberFormat: string;
72
- }
73
-
74
- // Enhanced TypeScript-compatible translation functions
75
- export function translate<T = string>(key: string, params?: TranslationParams, options?: TranslationOptions): T;
76
- export function translate<T = string>(key: TranslationKey<T>, params?: TranslationParams, options?: TranslationOptions): T;
77
-
78
- export const t: typeof translate;
79
-
80
- // Type-safe translation with strict typing
81
- export function tTyped<T = string>(key: string, params?: TranslationParams, options?: TranslationOptions): T;
82
-
83
- // Translation with encryption support
84
- export function translateEncrypted<T = string>(key: string, params?: TranslationParams, options?: TranslationOptions): Promise<T>;
85
-
86
- // Batch translation operations
87
- export function translateBatch<T = string>(keys: string[], params?: TranslationParams[], options?: TranslationOptions): T[];
88
- export function translateBatchEncrypted<T = string>(keys: string[], params?: TranslationParams[], options?: TranslationOptions): Promise<T[]>;
89
-
90
- // Configuration and initialization
91
- export function initI18nRuntime(options?: Partial<I18nConfig>): Promise<I18nRuntimeInstance>;
92
-
93
- export interface I18nRuntimeInstance {
94
- t: typeof translate;
95
- translate: typeof translate;
96
- translateEncrypted: typeof translateEncrypted;
97
- translateBatch: typeof translateBatch;
98
- translateBatchEncrypted: typeof translateBatchEncrypted;
99
-
100
- // Language management
101
- setLanguage: (lang: string) => Promise<void>;
102
- getLanguage: () => string;
103
- getAvailableLanguages: () => string[];
104
- refresh: (lang?: string) => Promise<void>;
105
-
106
- // Configuration
107
- getConfig: () => I18nConfig;
108
- updateConfig: (updates: Partial<I18nConfig>) => Promise<void>;
109
-
110
- // Security and encryption
111
- setEncryptionKey: (key: string) => void;
112
- getEncryptionStatus: () => boolean;
113
- encryptData: (data: string) => Promise<string>;
114
- decryptData: (encryptedData: string) => Promise<string>;
115
-
116
- // Validation and utilities
117
- validateTranslationKey: (key: string) => boolean;
118
- sanitizeTranslation: (text: string) => string;
119
- getTranslationMetadata: (key: string) => TranslationResult;
120
-
121
- // Type utilities
122
- createTypedTranslator<T>(): TypedTranslator<T>;
123
- }
124
-
125
- export interface TypedTranslator<T> {
126
- t: (key: string, params?: TranslationParams, options?: TranslationOptions) => T;
127
- translate: (key: string, params?: TranslationParams, options?: TranslationOptions) => T;
128
- }
129
-
130
- // Utility types for better TypeScript support
131
- export type TranslationNamespace = string;
132
- export type TranslationKeyPath = string;
133
- export type TranslationValue = string | number | boolean | null;
134
-
135
- export interface TranslationSchema {
136
- [key: string]: TranslationValue | TranslationSchema;
137
- }
138
-
139
- // Error handling types
140
- export interface TranslationError extends Error {
141
- code: string;
142
- key: string;
143
- language: string;
144
- params?: TranslationParams;
145
- }
146
-
147
- export interface ValidationError extends TranslationError {
148
- validationErrors: string[];
149
- }
150
-
151
- // Plugin system for extensibility
152
- export interface TranslationPlugin {
153
- name: string;
154
- version: string;
155
- transform?: (text: string, params: TranslationParams, options: TranslationOptions) => string;
156
- validate?: (key: string, params: TranslationParams) => boolean;
157
- encrypt?: (data: string, key: string) => Promise<string>;
158
- decrypt?: (encryptedData: string, key: string) => Promise<string>;
159
- }
160
-
161
- // Event system for monitoring
162
- export interface TranslationEvent {
163
- type: 'translation' | 'error' | 'validation' | 'encryption';
164
- key: string;
165
- language: string;
166
- params?: TranslationParams;
167
- result?: string;
168
- error?: TranslationError;
169
- timestamp: Date;
170
- duration: number;
171
- }
172
-
173
- export type TranslationEventHandler = (event: TranslationEvent) => void;
174
-
175
- // Performance monitoring
176
- export interface PerformanceMetrics {
177
- totalTranslations: number;
178
- cacheHitRate: number;
179
- averageTranslationTime: number;
180
- encryptionTime: number;
181
- memoryUsage: number;
182
- }
183
-
184
- // Advanced configuration builders
185
- export class I18nConfigBuilder {
186
- static create(): I18nConfigBuilder;
187
- withBaseDir(dir: string): I18nConfigBuilder;
188
- withDefaultLanguage(lang: string): I18nConfigBuilder;
189
- withEncryption(key: string): I18nConfigBuilder;
190
- withCache(enabled: boolean, maxSize?: number, ttl?: number): I18nConfigBuilder;
191
- withSecurity(options: Partial<I18nConfig['security']>): I18nConfigBuilder;
192
- build(): I18nConfig;
193
- }
194
-
195
- // Namespace management
196
- export interface NamespaceManager {
197
- addNamespace(name: string, translations: TranslationSchema): Promise<void>;
198
- removeNamespace(name: string): Promise<void>;
199
- getNamespace(name: string): TranslationSchema | null;
200
- listNamespaces(): string[];
201
- }
202
-
203
- // Migration utilities
204
- export interface MigrationOptions {
205
- fromVersion: string;
206
- toVersion: string;
207
- backup: boolean;
208
- dryRun: boolean;
209
- }
210
-
211
- export function migrateTranslations(options: MigrationOptions): Promise<MigrationResult>;
212
-
213
- export interface MigrationResult {
214
- success: boolean;
215
- migratedKeys: number;
216
- errors: string[];
217
- warnings: string[];
218
- backupPath?: string;
219
- }
220
-
221
- // Export compatibility with existing runtime
1
+ // runtime/enhanced.d.ts
2
+ // Enhanced runtime API with TypeScript support and AES-256-GCM encryption
3
+
4
+ export interface TranslationParams extends Record<string, unknown> {
5
+ count?: number;
6
+ context?: string;
7
+ [key: string]: unknown;
8
+ }
9
+
10
+ export interface TranslationOptions {
11
+ language?: string;
12
+ fallbackLanguage?: string;
13
+ namespace?: string;
14
+ encryptionKey?: string;
15
+ enableEncryption?: boolean;
16
+ }
17
+
18
+ export interface TranslationResult {
19
+ text: string;
20
+ language: string;
21
+ key: string;
22
+ params: TranslationParams;
23
+ encrypted: boolean;
24
+ }
25
+
26
+ export interface I18nConfig {
27
+ baseDir: string;
28
+ defaultLanguage: string;
29
+ fallbackLanguage: string;
30
+ keySeparator: string;
31
+ preload: boolean;
32
+ encryption: {
33
+ enabled: boolean;
34
+ algorithm: string;
35
+ keyLength: number;
36
+ ivLength: number;
37
+ authTagLength: number;
38
+ };
39
+ cache: {
40
+ enabled: boolean;
41
+ maxSize: number;
42
+ ttl: number;
43
+ };
44
+ security: {
45
+ validateInputs: boolean;
46
+ sanitizeOutput: boolean;
47
+ maxKeyLength: number;
48
+ maxValueLength: number;
49
+ };
50
+ }
51
+
52
+ export interface TranslationKey<T = string> {
53
+ key: string;
54
+ defaultValue?: T;
55
+ description?: string;
56
+ context?: string;
57
+ plural?: boolean;
58
+ }
59
+
60
+ export interface PluralizationRule {
61
+ rule: (count: number) => number;
62
+ examples: string[];
63
+ }
64
+
65
+ export interface LanguageConfig {
66
+ code: string;
67
+ name: string;
68
+ direction: 'ltr' | 'rtl';
69
+ pluralRules: PluralizationRule;
70
+ dateFormat: string;
71
+ numberFormat: string;
72
+ }
73
+
74
+ // Enhanced TypeScript-compatible translation functions
75
+ export function translate<T = string>(key: string, params?: TranslationParams, options?: TranslationOptions): T;
76
+ export function translate<T = string>(key: TranslationKey<T>, params?: TranslationParams, options?: TranslationOptions): T;
77
+
78
+ export const t: typeof translate;
79
+
80
+ // Type-safe translation with strict typing
81
+ export function tTyped<T = string>(key: string, params?: TranslationParams, options?: TranslationOptions): T;
82
+
83
+ // Translation with encryption support
84
+ export function translateEncrypted<T = string>(key: string, params?: TranslationParams, options?: TranslationOptions): Promise<T>;
85
+
86
+ // Batch translation operations
87
+ export function translateBatch<T = string>(keys: string[], params?: TranslationParams[], options?: TranslationOptions): T[];
88
+ export function translateBatchEncrypted<T = string>(keys: string[], params?: TranslationParams[], options?: TranslationOptions): Promise<T[]>;
89
+
90
+ // Configuration and initialization
91
+ export function initI18nRuntime(options?: Partial<I18nConfig>): Promise<I18nRuntimeInstance>;
92
+
93
+ export interface I18nRuntimeInstance {
94
+ t: typeof translate;
95
+ translate: typeof translate;
96
+ translateEncrypted: typeof translateEncrypted;
97
+ translateBatch: typeof translateBatch;
98
+ translateBatchEncrypted: typeof translateBatchEncrypted;
99
+
100
+ // Language management
101
+ setLanguage: (lang: string) => Promise<void>;
102
+ getLanguage: () => string;
103
+ getAvailableLanguages: () => string[];
104
+ refresh: (lang?: string) => Promise<void>;
105
+
106
+ // Configuration
107
+ getConfig: () => I18nConfig;
108
+ updateConfig: (updates: Partial<I18nConfig>) => Promise<void>;
109
+
110
+ // Security and encryption
111
+ setEncryptionKey: (key: string) => void;
112
+ getEncryptionStatus: () => boolean;
113
+ encryptData: (data: string) => Promise<string>;
114
+ decryptData: (encryptedData: string) => Promise<string>;
115
+
116
+ // Validation and utilities
117
+ validateTranslationKey: (key: string) => boolean;
118
+ sanitizeTranslation: (text: string) => string;
119
+ getTranslationMetadata: (key: string) => TranslationResult;
120
+
121
+ // Type utilities
122
+ createTypedTranslator<T>(): TypedTranslator<T>;
123
+ }
124
+
125
+ export interface TypedTranslator<T> {
126
+ t: (key: string, params?: TranslationParams, options?: TranslationOptions) => T;
127
+ translate: (key: string, params?: TranslationParams, options?: TranslationOptions) => T;
128
+ }
129
+
130
+ // Utility types for better TypeScript support
131
+ export type TranslationNamespace = string;
132
+ export type TranslationKeyPath = string;
133
+ export type TranslationValue = string | number | boolean | null;
134
+
135
+ export interface TranslationSchema {
136
+ [key: string]: TranslationValue | TranslationSchema;
137
+ }
138
+
139
+ // Error handling types
140
+ export interface TranslationError extends Error {
141
+ code: string;
142
+ key: string;
143
+ language: string;
144
+ params?: TranslationParams;
145
+ }
146
+
147
+ export interface ValidationError extends TranslationError {
148
+ validationErrors: string[];
149
+ }
150
+
151
+ // Plugin system for extensibility
152
+ export interface TranslationPlugin {
153
+ name: string;
154
+ version: string;
155
+ transform?: (text: string, params: TranslationParams, options: TranslationOptions) => string;
156
+ validate?: (key: string, params: TranslationParams) => boolean;
157
+ encrypt?: (data: string, key: string) => Promise<string>;
158
+ decrypt?: (encryptedData: string, key: string) => Promise<string>;
159
+ }
160
+
161
+ // Event system for monitoring
162
+ export interface TranslationEvent {
163
+ type: 'translation' | 'error' | 'validation' | 'encryption';
164
+ key: string;
165
+ language: string;
166
+ params?: TranslationParams;
167
+ result?: string;
168
+ error?: TranslationError;
169
+ timestamp: Date;
170
+ duration: number;
171
+ }
172
+
173
+ export type TranslationEventHandler = (event: TranslationEvent) => void;
174
+
175
+ // Performance monitoring
176
+ export interface PerformanceMetrics {
177
+ totalTranslations: number;
178
+ cacheHitRate: number;
179
+ averageTranslationTime: number;
180
+ encryptionTime: number;
181
+ memoryUsage: number;
182
+ }
183
+
184
+ // Advanced configuration builders
185
+ export class I18nConfigBuilder {
186
+ static create(): I18nConfigBuilder;
187
+ withBaseDir(dir: string): I18nConfigBuilder;
188
+ withDefaultLanguage(lang: string): I18nConfigBuilder;
189
+ withEncryption(key: string): I18nConfigBuilder;
190
+ withCache(enabled: boolean, maxSize?: number, ttl?: number): I18nConfigBuilder;
191
+ withSecurity(options: Partial<I18nConfig['security']>): I18nConfigBuilder;
192
+ build(): I18nConfig;
193
+ }
194
+
195
+ // Namespace management
196
+ export interface NamespaceManager {
197
+ addNamespace(name: string, translations: TranslationSchema): Promise<void>;
198
+ removeNamespace(name: string): Promise<void>;
199
+ getNamespace(name: string): TranslationSchema | null;
200
+ listNamespaces(): string[];
201
+ }
202
+
203
+ // Migration utilities
204
+ export interface MigrationOptions {
205
+ fromVersion: string;
206
+ toVersion: string;
207
+ backup: boolean;
208
+ dryRun: boolean;
209
+ }
210
+
211
+ export function migrateTranslations(options: MigrationOptions): Promise<MigrationResult>;
212
+
213
+ export interface MigrationResult {
214
+ success: boolean;
215
+ migratedKeys: number;
216
+ errors: string[];
217
+ warnings: string[];
218
+ backupPath?: string;
219
+ }
220
+
221
+ // Export compatibility with existing runtime
222
222
  export * from './index.d.ts';
@@ -1,29 +1,29 @@
1
- // runtime/index.d.ts
2
- // Public runtime API types for i18ntk
3
-
4
- export interface InitOptions {
5
- baseDir?: string;
6
- language?: string;
7
- fallbackLanguage?: string;
8
- keySeparator?: string;
9
- preload?: boolean;
10
- }
11
-
12
- export type TranslateParams = Record<string, unknown>;
13
-
14
- export function translate(key: string, params?: TranslateParams): string;
15
- export const t: typeof translate;
16
-
17
- export function initRuntime(options?: InitOptions): {
18
- t: typeof translate;
19
- translate: typeof translate;
20
- setLanguage: typeof setLanguage;
21
- getLanguage: typeof getLanguage;
22
- getAvailableLanguages: typeof getAvailableLanguages;
23
- refresh: typeof refresh;
24
- };
25
-
26
- export function setLanguage(lang: string): void;
27
- export function getLanguage(): string;
28
- export function getAvailableLanguages(): string[];
29
- export function refresh(lang?: string): void;
1
+ // runtime/index.d.ts
2
+ // Public runtime API types for i18ntk
3
+
4
+ export interface InitOptions {
5
+ baseDir?: string;
6
+ language?: string;
7
+ fallbackLanguage?: string;
8
+ keySeparator?: string;
9
+ preload?: boolean;
10
+ }
11
+
12
+ export type TranslateParams = Record<string, unknown>;
13
+
14
+ export function translate(key: string, params?: TranslateParams): string;
15
+ export const t: typeof translate;
16
+
17
+ export function initRuntime(options?: InitOptions): {
18
+ t: typeof translate;
19
+ translate: typeof translate;
20
+ setLanguage: typeof setLanguage;
21
+ getLanguage: typeof getLanguage;
22
+ getAvailableLanguages: typeof getAvailableLanguages;
23
+ refresh: typeof refresh;
24
+ };
25
+
26
+ export function setLanguage(lang: string): void;
27
+ export function getLanguage(): string;
28
+ export function getAvailableLanguages(): string[];
29
+ export function refresh(lang?: string): void;