From af65859ff87c357c15b250ee343927cef45944db Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Mon, 9 Jan 2023 09:26:54 -0800 Subject: [PATCH] fix: run comment translation logic on english builds (#48520) Co-authored-by: Oliver Eyton-Williams --- curriculum/getChallenges.js | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/curriculum/getChallenges.js b/curriculum/getChallenges.js index 154ed1e8c8d..d558dc6e0a4 100644 --- a/curriculum/getChallenges.js +++ b/curriculum/getChallenges.js @@ -34,9 +34,7 @@ const COMMENT_TRANSLATIONS = createCommentMap( function createCommentMap(dictionariesDir) { // get all the languages for which there are dictionaries. - const languages = fs - .readdirSync(dictionariesDir) - .filter(x => x !== 'english'); + const languages = fs.readdirSync(dictionariesDir); // get all their dictionaries const dictionaries = languages.reduce( @@ -363,18 +361,18 @@ Challenges that have been already audited cannot fall back to their English vers await validate(filePath, meta.superBlock); - const useEnglish = - lang === 'english' || - !isAuditedCert(lang, meta.superBlock) || - !fs.existsSync(getFullPath(lang, filePath)); + // We always try to translate comments (even English ones) to confirm that translations exist. + const translateComments = + isAuditedCert(lang, meta.superBlock) && + fs.existsSync(getFullPath(lang, filePath)); - const challenge = await (useEnglish - ? parseMD(getFullPath('english', filePath)) - : parseTranslation( + const challenge = await (translateComments + ? parseTranslation( getFullPath(lang, filePath), COMMENT_TRANSLATIONS, lang - )); + ) + : parseMD(getFullPath('english', filePath))); addMetaToChallenge(challenge, meta);