| 373 | |
| 374 | // Convert to TypeScript code |
| 375 | function objectToTypeScript(obj, indent = 0) { |
| 376 | const indentStr = '\t'.repeat(indent); |
| 377 | const lines = []; |
| 378 | |
| 379 | for (const [key, value] of Object.entries(obj)) { |
| 380 | if (typeof value === 'object' && value !== null) { |
| 381 | lines.push(`${indentStr}${key}: {`); |
| 382 | lines.push(objectToTypeScript(value, indent + 1)); |
| 383 | lines.push(`${indentStr}},`); |
| 384 | } else { |
| 385 | // Escape quotes and handle multiline strings |
| 386 | const escapedValue = value.replace(/\\/g, '\\\\').replace(/"/g, '\\"'); |
| 387 | lines.push(`${indentStr}${key}: "${escapedValue}",`); |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | return lines.join('\n'); |
| 392 | } |
| 393 | |
| 394 | const tsContent = `import { Translation } from "../types"; |
| 395 | |