diff --git a/script/i18n/reset-files-with-broken-liquid-tags.js b/script/i18n/reset-files-with-broken-liquid-tags.js index 8996d2f61f..987c191201 100644 --- a/script/i18n/reset-files-with-broken-liquid-tags.js +++ b/script/i18n/reset-files-with-broken-liquid-tags.js @@ -1,9 +1,9 @@ #!/usr/bin/env node import program from 'commander' +import { execSync } from 'child_process' import { languageFiles, compareLiquidTags } from '../../lib/liquid-tags/tokens.js' import languages from '../../lib/languages.js' -import fs from 'fs' program .description('show-liquid-tags-diff') @@ -12,15 +12,15 @@ program .parse(process.argv) function resetFiles(files) { - console.log(`Files to be reset (${files.length}): \n${files.join('\n')}`) + console.log(`Reseting ${files.length} files:`) + + const dryRun = program.opts().dryRun ? '--dry-run' : '' files.forEach((file) => { - // remove file so it falls back to English - console.log(`removing ${file}`) - - if (!program.opts().dryRun) { - fs.unlinkSync(file) - } + execSync( + `script/i18n/reset-translated-file.js ${file} --reason="broken liquid tags" ${dryRun}`, + { stdio: 'inherit' } + ) }) } diff --git a/script/i18n/reset-translated-file.js b/script/i18n/reset-translated-file.js index 952e7fbd46..844d79a049 100755 --- a/script/i18n/reset-translated-file.js +++ b/script/i18n/reset-translated-file.js @@ -57,10 +57,13 @@ const resetToEnglishSource = (translationFilePath) => { } if (!dryRun) { - // replace file with English source + // it is important to replace the file with English source instead of + // removing it, and relying on the fallback, because redired_from frontmatter + // won't work in fallbacks const englishContent = fs.readFileSync(englishFile, 'utf8') fs.writeFileSync(translationFilePath, englishContent) } + console.log( '-> reverted to English: %s %s', path.relative(process.cwd(), translationFilePath),