fix: comment dictionary with submodule (#55527)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Tom
2024-07-18 10:17:12 -05:00
committed by GitHub
parent 2c308aed62
commit d05a2cb7d4
3 changed files with 16 additions and 7 deletions
+1
View File
@@ -8,6 +8,7 @@ client/config/browser-scripts/*.json
client/static
curriculum/challenges/_meta/*/*
curriculum/challenges/**/*
curriculum/i18n-curriculum
docs/**/*.md
/playwright
pnpm-lock.yaml
+14 -6
View File
@@ -45,11 +45,11 @@ const COMMENT_TRANSLATIONS = createCommentMap(
);
function createCommentMap(dictionariesDir, englishDictionariesDir) {
// get all the languages for which there are dictionaries. Note: this has to
// include the english dictionaries since translateCommentsInChallenge treats
// all languages equally and will simply remove comments if there is no entry
// in the comment map.
const languages = fs.readdirSync(dictionariesDir);
// get all the languages for which there are dictionaries. Note: the english
// entries are created separately, so we remove it from languages.
const languages = fs
.readdirSync(dictionariesDir)
.filter(lang => lang !== 'english'); // TODO: Remove the filter after migrating to i18n-curriculum
// get all their dictionaries
const dictionaries = languages.reduce(
@@ -101,7 +101,15 @@ function createCommentMap(dictionariesDir, englishDictionariesDir) {
};
}, {});
return { ...translatedCommentMap, ...untranslatableCommentMap };
const allComments = { ...translatedCommentMap, ...untranslatableCommentMap };
// the english entries need to be added here, because english is not in
// languages
Object.keys(allComments).forEach(comment => {
allComments[comment].english = comment;
});
return allComments;
}
exports.createCommentMap = createCommentMap;