From d05a2cb7d47834693458967df7beb8147579efae Mon Sep 17 00:00:00 2001 From: Tom <20648924+moT01@users.noreply.github.com> Date: Thu, 18 Jul 2024 10:17:12 -0500 Subject: [PATCH] fix: comment dictionary with submodule (#55527) Co-authored-by: Oliver Eyton-Williams --- .prettierignore | 1 + curriculum/get-challenges.js | 20 ++++++++++++++------ curriculum/i18n-curriculum | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.prettierignore b/.prettierignore index ebcc37a5835..ea3e07b8f76 100644 --- a/.prettierignore +++ b/.prettierignore @@ -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 diff --git a/curriculum/get-challenges.js b/curriculum/get-challenges.js index 3a39ab939f4..9a67aafceac 100644 --- a/curriculum/get-challenges.js +++ b/curriculum/get-challenges.js @@ -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; diff --git a/curriculum/i18n-curriculum b/curriculum/i18n-curriculum index 531d189f02b..6659d0702ae 160000 --- a/curriculum/i18n-curriculum +++ b/curriculum/i18n-curriculum @@ -1 +1 @@ -Subproject commit 531d189f02b4b13e81f18a4b3558bb4482048473 +Subproject commit 6659d0702ae0bf76002b057c59e1b6a64e08d3c0