auto-translate-json-library 1.5.5 → 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/README.MD +1141 -148
  2. package/build/package.json +96 -22
  3. package/build/src/aws.d.ts +1 -1
  4. package/build/src/aws.js +27 -38
  5. package/build/src/azure.d.ts +1 -1
  6. package/build/src/azure.js +50 -64
  7. package/build/src/bin/cli.d.ts +1 -1
  8. package/build/src/bin/cli.js +196 -37
  9. package/build/src/config.d.ts +1 -0
  10. package/build/src/config.js +1 -2
  11. package/build/src/deepl.d.ts +1 -1
  12. package/build/src/deepl.js +18 -64
  13. package/build/src/files.d.ts +11 -2
  14. package/build/src/files.js +356 -69
  15. package/build/src/folderFiles.d.ts +6 -3
  16. package/build/src/folderFiles.js +33 -44
  17. package/build/src/format/arb-handler.d.ts +33 -0
  18. package/build/src/format/arb-handler.js +679 -0
  19. package/build/src/format/base-format-handler.d.ts +75 -0
  20. package/build/src/format/base-format-handler.js +166 -0
  21. package/build/src/format/csv-handler.d.ts +38 -0
  22. package/build/src/format/csv-handler.js +604 -0
  23. package/build/src/format/index.d.ts +17 -0
  24. package/build/src/format/index.js +48 -0
  25. package/build/src/format/json-handler.d.ts +17 -0
  26. package/build/src/format/json-handler.js +294 -0
  27. package/build/src/format/po-handler.d.ts +17 -0
  28. package/build/src/format/po-handler.js +338 -0
  29. package/build/src/format/po-utils.d.ts +86 -0
  30. package/build/src/format/po-utils.js +385 -0
  31. package/build/src/format/pot-handler.d.ts +22 -0
  32. package/build/src/format/pot-handler.js +331 -0
  33. package/build/src/format/properties-handler.d.ts +26 -0
  34. package/build/src/format/properties-handler.js +500 -0
  35. package/build/src/format/tsv-handler.d.ts +13 -0
  36. package/build/src/format/tsv-handler.js +67 -0
  37. package/build/src/format/xliff-handler.d.ts +24 -0
  38. package/build/src/format/xliff-handler.js +433 -0
  39. package/build/src/format/xmb-handler.d.ts +33 -0
  40. package/build/src/format/xmb-handler.js +484 -0
  41. package/build/src/format/xmb-xtb-utils.d.ts +43 -0
  42. package/build/src/format/xmb-xtb-utils.js +180 -0
  43. package/build/src/format/xml-handler.d.ts +28 -0
  44. package/build/src/format/xml-handler.js +561 -0
  45. package/build/src/format/xtb-handler.d.ts +33 -0
  46. package/build/src/format/xtb-handler.js +518 -0
  47. package/build/src/format/yaml-handler.d.ts +26 -0
  48. package/build/src/format/yaml-handler.js +522 -0
  49. package/build/src/format-detector.d.ts +7 -0
  50. package/build/src/format-detector.js +58 -0
  51. package/build/src/format-handler-factory.d.ts +9 -0
  52. package/build/src/format-handler-factory.js +18 -0
  53. package/build/src/format.interface.d.ts +56 -0
  54. package/build/src/format.interface.js +1 -0
  55. package/build/src/google.d.ts +1 -1
  56. package/build/src/google.js +32 -49
  57. package/build/src/index.d.ts +4 -3
  58. package/build/src/index.js +15 -17
  59. package/build/src/lib.d.ts +1 -1
  60. package/build/src/lib.js +188 -133
  61. package/build/src/openai.d.ts +2 -2
  62. package/build/src/openai.js +59 -50
  63. package/build/src/translate.interface.d.ts +1 -1
  64. package/build/src/translate.interface.js +1 -2
  65. package/build/src/util.js +4 -9
  66. package/build/src/validation/enhanced-validation-result.d.ts +96 -0
  67. package/build/src/validation/enhanced-validation-result.js +198 -0
  68. package/build/src/validation/error-messages.d.ts +88 -0
  69. package/build/src/validation/error-messages.js +436 -0
  70. package/build/src/validation/error-recovery.d.ts +78 -0
  71. package/build/src/validation/error-recovery.js +593 -0
  72. package/build/src/validation/example-usage.d.ts +31 -0
  73. package/build/src/validation/example-usage.js +148 -0
  74. package/build/src/validation/format-rules.d.ts +37 -0
  75. package/build/src/validation/format-rules.js +550 -0
  76. package/build/src/validation/format-validator.d.ts +70 -0
  77. package/build/src/validation/format-validator.js +279 -0
  78. package/build/src/validation/index.d.ts +13 -0
  79. package/build/src/validation/index.js +30 -0
  80. package/build/src/validation/validation-service.d.ts +56 -0
  81. package/build/src/validation/validation-service.js +262 -0
  82. package/build/tests/arb-handler.test.d.ts +1 -0
  83. package/build/tests/arb-handler.test.js +694 -0
  84. package/build/tests/cli-integration.test.d.ts +1 -0
  85. package/build/tests/cli-integration.test.js +352 -0
  86. package/build/tests/csv-handler.test.d.ts +1 -0
  87. package/build/tests/csv-handler.test.js +507 -0
  88. package/build/tests/error-handling.test.d.ts +1 -0
  89. package/build/tests/error-handling.test.js +456 -0
  90. package/build/tests/files-integration.test.d.ts +1 -0
  91. package/build/tests/files-integration.test.js +421 -0
  92. package/build/tests/json-handler.test.d.ts +1 -0
  93. package/build/tests/json-handler.test.js +526 -0
  94. package/build/tests/po-handler.test.d.ts +1 -0
  95. package/build/tests/po-handler.test.js +768 -0
  96. package/build/tests/properties-handler.test.d.ts +1 -0
  97. package/build/tests/properties-handler.test.js +316 -0
  98. package/build/tests/setup.d.ts +1 -0
  99. package/build/tests/setup.js +5 -0
  100. package/build/tests/xliff-handler.test.d.ts +1 -0
  101. package/build/tests/xliff-handler.test.js +459 -0
  102. package/build/tests/xmb-xtb-handler.test.d.ts +1 -0
  103. package/build/tests/xmb-xtb-handler.test.js +758 -0
  104. package/build/tests/xml-handler.test.d.ts +1 -0
  105. package/build/tests/xml-handler.test.js +570 -0
  106. package/build/tests/yaml-handler.test.d.ts +1 -0
  107. package/build/tests/yaml-handler.test.js +156 -0
  108. package/package.json +96 -22
@@ -0,0 +1,436 @@
1
+ /**
2
+ * Error message templates and localization support for validation errors
3
+ */
4
+ /**
5
+ * Error message templates organized by category
6
+ */
7
+ export const errorMessageTemplates = {
8
+ // Structure errors
9
+ INVALID_STRUCTURE: {
10
+ code: "INVALID_STRUCTURE",
11
+ template: "Invalid file structure: {message}",
12
+ description: "The file structure does not conform to the expected format",
13
+ severity: "error",
14
+ category: "structure",
15
+ actionable: true,
16
+ suggestion: "Ensure the file follows the correct format specification",
17
+ },
18
+ EMPTY_TRANSLATION_FILE: {
19
+ code: "EMPTY_TRANSLATION_FILE",
20
+ template: "Translation file is empty or contains no translatable content",
21
+ description: "The file does not contain any translatable strings",
22
+ severity: "warning",
23
+ category: "content",
24
+ actionable: true,
25
+ suggestion: "Add translatable content to the file",
26
+ },
27
+ CIRCULAR_REFERENCE: {
28
+ code: "CIRCULAR_REFERENCE",
29
+ template: "Circular reference detected in translation data",
30
+ description: "The translation data contains circular object references",
31
+ severity: "error",
32
+ category: "structure",
33
+ actionable: true,
34
+ suggestion: "Remove circular references from the data structure",
35
+ },
36
+ // Format-specific errors
37
+ JSON_CIRCULAR_REFERENCE: {
38
+ code: "JSON_CIRCULAR_REFERENCE",
39
+ template: "JSON data contains circular references that cannot be serialized",
40
+ description: "JSON format does not support circular object references",
41
+ severity: "error",
42
+ category: "format",
43
+ actionable: true,
44
+ suggestion: "Restructure the data to avoid circular references",
45
+ },
46
+ JSON_DEEP_NESTING: {
47
+ code: "JSON_DEEP_NESTING",
48
+ template: "JSON structure is deeply nested (depth > {maxDepth}) at {path}",
49
+ description: "Excessive nesting can cause performance issues and make the file hard to maintain",
50
+ severity: "warning",
51
+ category: "structure",
52
+ actionable: true,
53
+ suggestion: "Consider flattening the structure or breaking it into smaller files",
54
+ },
55
+ // XLIFF-specific errors
56
+ XLIFF_MISSING_VERSION: {
57
+ code: "XLIFF_MISSING_VERSION",
58
+ template: "XLIFF file is missing version information",
59
+ description: "XLIFF files should specify their version for proper processing",
60
+ severity: "warning",
61
+ category: "metadata",
62
+ actionable: true,
63
+ suggestion: 'Add version attribute to the XLIFF root element (e.g., version="1.2")',
64
+ },
65
+ XLIFF_INVALID_VERSION: {
66
+ code: "XLIFF_INVALID_VERSION",
67
+ template: "Unsupported XLIFF version: {version}. Supported versions are {supportedVersions}",
68
+ description: "The XLIFF version is not supported by this tool",
69
+ severity: "error",
70
+ category: "format",
71
+ actionable: true,
72
+ suggestion: "Use a supported XLIFF version (1.2, 2.0, or 2.1)",
73
+ },
74
+ XLIFF_MISSING_SOURCE_LANGUAGE: {
75
+ code: "XLIFF_MISSING_SOURCE_LANGUAGE",
76
+ template: "XLIFF file should specify source language information",
77
+ description: "Source language helps with proper translation processing",
78
+ severity: "warning",
79
+ category: "metadata",
80
+ actionable: true,
81
+ suggestion: "Add source-language attribute to the file element",
82
+ },
83
+ XLIFF_MISSING_TARGET_LANGUAGE: {
84
+ code: "XLIFF_MISSING_TARGET_LANGUAGE",
85
+ template: "XLIFF file should specify target language information",
86
+ description: "Target language helps with proper translation processing",
87
+ severity: "warning",
88
+ category: "metadata",
89
+ actionable: true,
90
+ suggestion: "Add target-language attribute to the file element",
91
+ },
92
+ // ARB-specific errors
93
+ ARB_MISSING_LOCALE: {
94
+ code: "ARB_MISSING_LOCALE",
95
+ template: "ARB file should contain @@locale metadata to specify the language",
96
+ description: "The @@locale metadata helps identify the language of the ARB file",
97
+ severity: "warning",
98
+ category: "metadata",
99
+ actionable: true,
100
+ suggestion: 'Add "@@locale": "language_code" to the ARB file (e.g., "en", "es_ES")',
101
+ },
102
+ ARB_INVALID_LOCALE: {
103
+ code: "ARB_INVALID_LOCALE",
104
+ template: 'Invalid locale format: "{locale}". Expected format: language[_COUNTRY]',
105
+ description: "Locale codes should follow standard language and country code format",
106
+ severity: "warning",
107
+ category: "metadata",
108
+ actionable: true,
109
+ suggestion: 'Use format like "en", "en_US", "es_ES", "fr_CA"',
110
+ },
111
+ ARB_ICU_SYNTAX_ERROR: {
112
+ code: "ARB_ICU_SYNTAX_ERROR",
113
+ template: 'ICU message format syntax error in "{path}": {error}',
114
+ description: "The ICU message format syntax is invalid and may cause runtime errors",
115
+ severity: "error",
116
+ category: "syntax",
117
+ actionable: true,
118
+ suggestion: "Fix the ICU syntax error. Common issues: unmatched brackets, missing commas, invalid placeholders",
119
+ documentation: "https://unicode-org.github.io/icu/userguide/format_parse/messages/",
120
+ },
121
+ ARB_ORPHANED_METADATA: {
122
+ code: "ARB_ORPHANED_METADATA",
123
+ template: "Resource metadata @{resourceName} has no corresponding resource",
124
+ description: "Metadata exists for a resource that is not defined",
125
+ severity: "warning",
126
+ category: "metadata",
127
+ actionable: true,
128
+ suggestion: "Either add the missing resource or remove the orphaned metadata",
129
+ },
130
+ // PO-specific errors
131
+ PO_MISSING_HEADER: {
132
+ code: "PO_MISSING_HEADER",
133
+ template: "PO file should contain header information for proper processing",
134
+ description: "PO file headers contain important metadata like language, encoding, and plural forms",
135
+ severity: "warning",
136
+ category: "metadata",
137
+ actionable: true,
138
+ suggestion: "Add PO file header with Language, Content-Type, and Plural-Forms fields",
139
+ },
140
+ PO_UNTRANSLATED_STRINGS: {
141
+ code: "PO_UNTRANSLATED_STRINGS",
142
+ template: "Found {count} untranslated strings in PO file",
143
+ description: "Some strings in the PO file have not been translated",
144
+ severity: "info",
145
+ category: "content",
146
+ actionable: true,
147
+ suggestion: "Complete the translation of remaining strings",
148
+ },
149
+ // Content validation errors
150
+ EMPTY_TRANSLATION_STRING: {
151
+ code: "EMPTY_TRANSLATION_STRING",
152
+ template: "Empty or whitespace-only translation string at {path}",
153
+ description: "Translation strings should contain meaningful content",
154
+ severity: "warning",
155
+ category: "content",
156
+ actionable: true,
157
+ suggestion: "Provide a translation for this string or remove it if not needed",
158
+ },
159
+ VERY_LONG_STRING: {
160
+ code: "VERY_LONG_STRING",
161
+ template: "Translation string at {path} is very long ({length} characters)",
162
+ description: "Very long strings may indicate data issues or poor user experience",
163
+ severity: "info",
164
+ category: "content",
165
+ actionable: false,
166
+ suggestion: "Consider breaking long text into smaller, more manageable pieces",
167
+ },
168
+ CONTROL_CHARACTERS: {
169
+ code: "CONTROL_CHARACTERS",
170
+ template: "Translation string at {path} contains control characters",
171
+ description: "Control characters may cause display or processing issues",
172
+ severity: "warning",
173
+ category: "content",
174
+ actionable: true,
175
+ suggestion: "Remove or properly escape control characters",
176
+ },
177
+ NON_TRANSLATABLE_VALUE: {
178
+ code: "NON_TRANSLATABLE_VALUE",
179
+ template: "Value at {path} is not translatable ({type})",
180
+ description: "Only string values should be translated",
181
+ severity: "warning",
182
+ category: "content",
183
+ actionable: false,
184
+ suggestion: "Non-string values will be preserved as-is during translation",
185
+ },
186
+ // Key validation errors
187
+ DUPLICATE_KEYS: {
188
+ code: "DUPLICATE_KEYS",
189
+ template: "Duplicate translation key found: {key}",
190
+ description: "Duplicate keys can cause conflicts and unpredictable behavior",
191
+ severity: "error",
192
+ category: "structure",
193
+ actionable: true,
194
+ suggestion: "Ensure all translation keys are unique",
195
+ },
196
+ KEY_CONTAINS_SPACES: {
197
+ code: "KEY_CONTAINS_SPACES",
198
+ template: 'Translation key "{key}" contains spaces',
199
+ description: "Keys with spaces may cause issues in some systems",
200
+ severity: "warning",
201
+ category: "structure",
202
+ actionable: true,
203
+ suggestion: "Consider using underscores, camelCase, or kebab-case instead of spaces",
204
+ },
205
+ KEY_INVALID_DASH: {
206
+ code: "KEY_INVALID_DASH",
207
+ template: 'Translation key "{key}" starts or ends with dash',
208
+ description: "Keys starting or ending with dashes may cause parsing issues",
209
+ severity: "warning",
210
+ category: "structure",
211
+ actionable: true,
212
+ suggestion: "Remove leading or trailing dashes from the key",
213
+ },
214
+ KEY_SPECIAL_CHARACTERS: {
215
+ code: "KEY_SPECIAL_CHARACTERS",
216
+ template: 'Translation key "{key}" contains special characters',
217
+ description: "Special characters in keys may cause compatibility issues",
218
+ severity: "info",
219
+ category: "structure",
220
+ actionable: false,
221
+ suggestion: "Consider using only alphanumeric characters, dots, underscores, and dashes",
222
+ },
223
+ // Properties-specific errors
224
+ PROPERTIES_UNESCAPED_UNICODE: {
225
+ code: "PROPERTIES_UNESCAPED_UNICODE",
226
+ template: 'Unescaped Unicode characters in Properties key "{key}"',
227
+ description: "Properties files may require Unicode escaping for non-ASCII characters",
228
+ severity: "warning",
229
+ category: "format",
230
+ actionable: true,
231
+ suggestion: "Use Unicode escapes (\\uXXXX) for non-ASCII characters or ensure UTF-8 encoding",
232
+ },
233
+ // YAML-specific errors
234
+ YAML_NON_STRING_VALUE: {
235
+ code: "YAML_NON_STRING_VALUE",
236
+ template: "Non-string value at {path} ({type}) in YAML file",
237
+ description: "Only string values should be translated in YAML files",
238
+ severity: "warning",
239
+ category: "content",
240
+ actionable: false,
241
+ suggestion: "Non-string values will be preserved as-is during translation",
242
+ },
243
+ // CSV-specific errors
244
+ CSV_NO_DATA: {
245
+ code: "CSV_NO_DATA",
246
+ template: "CSV file contains no data rows",
247
+ description: "CSV file should contain at least one data row",
248
+ severity: "error",
249
+ category: "content",
250
+ actionable: true,
251
+ suggestion: "Add data rows to the CSV file",
252
+ },
253
+ CSV_INCONSISTENT_COLUMNS: {
254
+ code: "CSV_INCONSISTENT_COLUMNS",
255
+ template: "CSV file has inconsistent number of columns",
256
+ description: "All rows in a CSV file should have the same number of columns",
257
+ severity: "error",
258
+ category: "structure",
259
+ actionable: true,
260
+ suggestion: "Ensure all rows have the same number of columns",
261
+ },
262
+ // Generic validation errors
263
+ VALIDATION_RULE_ERROR: {
264
+ code: "VALIDATION_RULE_ERROR",
265
+ template: "Validation rule failed: {error}",
266
+ description: "An error occurred while running a validation rule",
267
+ severity: "warning",
268
+ category: "structure",
269
+ actionable: false,
270
+ suggestion: "This may indicate a bug in the validation system",
271
+ },
272
+ EMPTY_CONTENT: {
273
+ code: "EMPTY_CONTENT",
274
+ template: "File content is empty",
275
+ description: "The file does not contain any content",
276
+ severity: "error",
277
+ category: "content",
278
+ actionable: true,
279
+ suggestion: "Add content to the file",
280
+ },
281
+ VERY_LARGE_FILE: {
282
+ code: "VERY_LARGE_FILE",
283
+ template: "File is very large ({size}MB) and may cause performance issues",
284
+ description: "Large files may take longer to process and consume more memory",
285
+ severity: "warning",
286
+ category: "content",
287
+ actionable: false,
288
+ suggestion: "Consider breaking large files into smaller chunks",
289
+ },
290
+ };
291
+ /**
292
+ * Error message formatter with template interpolation and localization support
293
+ */
294
+ export class ErrorMessageFormatter {
295
+ static locale = "en";
296
+ static customTemplates = {};
297
+ /**
298
+ * Set the locale for error messages (for future localization)
299
+ */
300
+ static setLocale(locale) {
301
+ this.locale = locale;
302
+ }
303
+ /**
304
+ * Register custom error message templates
305
+ */
306
+ static registerCustomTemplates(templates) {
307
+ Object.assign(this.customTemplates, templates);
308
+ }
309
+ /**
310
+ * Format an error message with context interpolation
311
+ */
312
+ static formatMessage(code, context = {}) {
313
+ const template = this.customTemplates[code] || errorMessageTemplates[code];
314
+ if (!template) {
315
+ return `Unknown error: ${code}`;
316
+ }
317
+ return this.interpolateTemplate(template.template, context);
318
+ }
319
+ /**
320
+ * Get detailed error information including suggestions and documentation
321
+ */
322
+ static getErrorDetails(code) {
323
+ return this.customTemplates[code] || errorMessageTemplates[code] || null;
324
+ }
325
+ /**
326
+ * Format a complete error message with details and suggestions
327
+ */
328
+ static formatDetailedMessage(code, context = {}) {
329
+ const template = this.getErrorDetails(code);
330
+ if (!template) {
331
+ return `Unknown error: ${code}`;
332
+ }
333
+ let message = this.interpolateTemplate(template.template, context);
334
+ if (template.suggestion) {
335
+ message += `\n Suggestion: ${template.suggestion}`;
336
+ }
337
+ if (template.documentation) {
338
+ message += `\n Documentation: ${template.documentation}`;
339
+ }
340
+ return message;
341
+ }
342
+ /**
343
+ * Get error severity level
344
+ */
345
+ static getErrorSeverity(code) {
346
+ const template = this.getErrorDetails(code);
347
+ return template?.severity || "error";
348
+ }
349
+ /**
350
+ * Check if an error is actionable (can be fixed by the user)
351
+ */
352
+ static isActionable(code) {
353
+ const template = this.getErrorDetails(code);
354
+ return template?.actionable || false;
355
+ }
356
+ /**
357
+ * Get errors by category
358
+ */
359
+ static getErrorsByCategory(category) {
360
+ const allTemplates = { ...errorMessageTemplates, ...this.customTemplates };
361
+ return Object.values(allTemplates).filter((template) => template.category === category);
362
+ }
363
+ /**
364
+ * Interpolate template variables with context values
365
+ */
366
+ static interpolateTemplate(template, context) {
367
+ return template.replace(/\{(\w+)\}/g, (match, key) => {
368
+ const value = context[key];
369
+ if (value !== undefined) {
370
+ return String(value);
371
+ }
372
+ return match; // Keep placeholder if no value provided
373
+ });
374
+ }
375
+ /**
376
+ * Create a formatted error message for display in CLI or UI
377
+ */
378
+ static createDisplayMessage(code, context = {}, includeDetails = false) {
379
+ const template = this.getErrorDetails(code);
380
+ if (!template) {
381
+ return `[${code}] Unknown error`;
382
+ }
383
+ const severityIcon = this.getSeverityIcon(template.severity);
384
+ const message = this.interpolateTemplate(template.template, context);
385
+ let displayMessage = `${severityIcon} [${code}] ${message}`;
386
+ if (context.filePath) {
387
+ displayMessage += ` (${context.filePath}`;
388
+ if (context.line) {
389
+ displayMessage += `:${context.line}`;
390
+ if (context.column) {
391
+ displayMessage += `:${context.column}`;
392
+ }
393
+ }
394
+ displayMessage += ")";
395
+ }
396
+ if (includeDetails && template.suggestion) {
397
+ displayMessage += `\n 💡 ${template.suggestion}`;
398
+ }
399
+ return displayMessage;
400
+ }
401
+ /**
402
+ * Get icon for severity level
403
+ */
404
+ static getSeverityIcon(severity) {
405
+ switch (severity) {
406
+ case "error":
407
+ return "❌";
408
+ case "warning":
409
+ return "âš ī¸";
410
+ case "info":
411
+ return "â„šī¸";
412
+ default:
413
+ return "❓";
414
+ }
415
+ }
416
+ /**
417
+ * Create a summary of validation results
418
+ */
419
+ static createValidationSummary(errors, warnings) {
420
+ const errorCount = errors.length;
421
+ const warningCount = warnings.length;
422
+ if (errorCount === 0 && warningCount === 0) {
423
+ return "✅ No validation issues found";
424
+ }
425
+ let summary = "";
426
+ if (errorCount > 0) {
427
+ summary += `❌ ${errorCount} error${errorCount === 1 ? "" : "s"}`;
428
+ }
429
+ if (warningCount > 0) {
430
+ if (summary)
431
+ summary += ", ";
432
+ summary += `âš ī¸ ${warningCount} warning${warningCount === 1 ? "" : "s"}`;
433
+ }
434
+ return summary;
435
+ }
436
+ }
@@ -0,0 +1,78 @@
1
+ import type { TranslationFile } from "../translate.interface.js";
2
+ /**
3
+ * Recovery strategy for handling corrupted or problematic files
4
+ */
5
+ export interface RecoveryStrategy {
6
+ name: string;
7
+ description: string;
8
+ canRecover: (error: Error, content: string, filePath?: string) => boolean;
9
+ recover: (error: Error, content: string, filePath?: string) => RecoveryResult;
10
+ }
11
+ /**
12
+ * Result of a recovery attempt
13
+ */
14
+ export interface RecoveryResult {
15
+ success: boolean;
16
+ data?: TranslationFile;
17
+ warnings: string[];
18
+ errors: string[];
19
+ recoveryMethod: string;
20
+ originalError: string;
21
+ partialRecovery?: boolean;
22
+ }
23
+ /**
24
+ * Error recovery manager that attempts to salvage data from corrupted files
25
+ */
26
+ export declare class ErrorRecoveryManager {
27
+ private static strategies;
28
+ /**
29
+ * Register a recovery strategy
30
+ */
31
+ static registerStrategy(strategy: RecoveryStrategy): void;
32
+ /**
33
+ * Attempt to recover data from a corrupted file
34
+ */
35
+ static attemptRecovery(error: Error, content: string, filePath?: string): RecoveryResult;
36
+ /**
37
+ * Get all registered recovery strategies
38
+ */
39
+ static getStrategies(): RecoveryStrategy[];
40
+ /**
41
+ * Clear all strategies (useful for testing)
42
+ */
43
+ static clearStrategies(): void;
44
+ }
45
+ /**
46
+ * JSON recovery strategies
47
+ */
48
+ export declare const jsonRecoveryStrategies: RecoveryStrategy[];
49
+ /**
50
+ * XML recovery strategies
51
+ */
52
+ export declare const xmlRecoveryStrategies: RecoveryStrategy[];
53
+ /**
54
+ * Format fallback strategies
55
+ */
56
+ export declare const formatFallbackStrategies: RecoveryStrategy[];
57
+ /**
58
+ * Initialize all recovery strategies
59
+ */
60
+ export declare function initializeErrorRecovery(): void;
61
+ /**
62
+ * User guidance system for common format issues
63
+ */
64
+ export declare class UserGuidanceSystem {
65
+ private static commonIssues;
66
+ /**
67
+ * Get guidance for a specific error type
68
+ */
69
+ static getGuidance(errorType: string): string[];
70
+ /**
71
+ * Add custom guidance for an error type
72
+ */
73
+ static addGuidance(errorType: string, guidance: string[]): void;
74
+ /**
75
+ * Get formatted guidance message
76
+ */
77
+ static getFormattedGuidance(errorType: string, error?: Error): string;
78
+ }