fix_empty_translations.js 723 B

123456789101112131415161718192021
  1. const fs = require('fs');
  2. const path = require('path');
  3. const translationsPath = path.join('d:', 'workspace', 'AuraK', 'web', 'utils', 'translations.ts');
  4. let content = fs.readFileSync(translationsPath, 'utf8');
  5. // Fix the specific syntax error first: key: , -> key: "key",
  6. const lines = content.split('\n');
  7. const fixedLines = lines.map(line => {
  8. const match = line.match(/^(\s+)(["']?[a-zA-Z0-9_-]+["']?):\s*,/);
  9. if (match) {
  10. const indent = match[1];
  11. const key = match[2].replace(/['"]/g, '');
  12. return `${indent}${match[2]}: "${key}",`;
  13. }
  14. return line;
  15. });
  16. fs.writeFileSync(translationsPath, fixedLines.join('\n'), 'utf8');
  17. console.log('Fixed empty values in translations.ts!');