Skip to content

Commit

Permalink
fix: gotta account for the slug too I guess? (freeCodeCamp#53356)
Browse files Browse the repository at this point in the history
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
  • Loading branch information
Mama Naomi and ojeytonwilliams authored Jan 26, 2024
1 parent 03b7390 commit 987fe44
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tools/scripts/sync-i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,30 @@ const syncChallenges = async () => {
const langContent = await readFile(targetPath, 'utf-8');
const engLines = englishContent.split('\n');
const engId = engLines.find(l => l.startsWith('id'));
const engSlug = engLines.find(l => l.startsWith('dashedName'));
const langLines = langContent.split('\n');
const langId = langLines.find(l => l.startsWith('id'));
if (engId && langId && engId !== langId) {
const langSlug = langLines.find(l => l.startsWith('dashedName'));
if (!langSlug) {
throw new Error(
`Missing dashedName for ${targetPath}. Please add it so that it matches the English version.`
);
}
if (!langId) {
throw new Error(
`Missing id for ${targetPath}. Please add it so that it matches the English version.`
);
}
if (engId && engId !== langId) {
langLines.splice(langLines.indexOf(langId), 1, engId);
console.log(`Updating ID for ${targetPath}`);
await writeFile(targetPath, langLines.join('\n'), 'utf-8');
}
if (engSlug && engSlug !== langSlug) {
langLines.splice(langLines.indexOf(langSlug), 1, engSlug);
console.log(`Updating dashed name for ${targetPath}`);
await writeFile(targetPath, langLines.join('\n'), 'utf-8');
}
})
);
}
Expand Down

0 comments on commit 987fe44

Please sign in to comment.