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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 7 deletions

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

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;

@ -1 +1 @@
Subproject commit 531d189f02b4b13e81f18a4b3558bb4482048473
Subproject commit 6659d0702ae0bf76002b057c59e1b6a64e08d3c0