From a378bc6dd4a2600a9c6a5c214bff02fb51bc63a3 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra <1884376+raisedadead@users.noreply.github.com> Date: Tue, 15 Jun 2021 23:07:52 +0530 Subject: [PATCH] chore: rework the language audits for build (#42510) This also reverts commit cd5c28b332154cbecd4edf2d25b38ceb6ede771b. --- client/src/components/Map/index.js | 2 +- .../Introduction/components/Block.js | 2 +- config/i18n/all-langs.js | 48 ++++++++++++++++++- curriculum/getChallenges.js | 2 +- curriculum/test/test-challenges.js | 2 +- {config => utils}/is-audited.js | 27 +---------- 6 files changed, 52 insertions(+), 31 deletions(-) rename {config => utils}/is-audited.js (53%) diff --git a/client/src/components/Map/index.js b/client/src/components/Map/index.js index d16dc7daa7..3675c3f59b 100644 --- a/client/src/components/Map/index.js +++ b/client/src/components/Map/index.js @@ -7,7 +7,7 @@ import { generateIconComponent } from '../../assets/icons'; import { Link, Spacer } from '../helpers'; import LinkButton from '../../assets/icons/LinkButton'; import './map.css'; -import { isAuditedCert } from '../../../../config/is-audited'; +import { isAuditedCert } from '../../../../utils/is-audited'; import envData from '../../../../config/env.json'; const { curriculumLocale } = envData; diff --git a/client/src/templates/Introduction/components/Block.js b/client/src/templates/Introduction/components/Block.js index 3a2c7374e8..5fa04530e2 100644 --- a/client/src/templates/Introduction/components/Block.js +++ b/client/src/templates/Introduction/components/Block.js @@ -12,7 +12,7 @@ import Challenges from './Challenges'; import Caret from '../../../assets/icons/Caret'; import GreenPass from '../../../assets/icons/GreenPass'; import GreenNotCompleted from '../../../assets/icons/GreenNotCompleted'; -import { isAuditedCert } from '../../../../../config/is-audited'; +import { isAuditedCert } from '../../../../../utils/is-audited'; import envData from '../../../../../config/env.json'; import { Link } from '../../../components/helpers/'; diff --git a/config/i18n/all-langs.js b/config/i18n/all-langs.js index 4a3c2df9cb..9cf5bbe9fa 100644 --- a/config/i18n/all-langs.js +++ b/config/i18n/all-langs.js @@ -1,4 +1,11 @@ -/* An error will be thrown if the CLIENT_LOCALE and CURRICULUM_LOCALE variables +// --------------------------------------------------------------------------- + +/* + * List of languages with localizations enabled for builds. + * + * Client is the UI, and Curriculum is the Challenge Content. + * + * An error will be thrown if the CLIENT_LOCALE and CURRICULUM_LOCALE variables * from the .env file aren't found in their respective arrays below */ const availableLangs = { @@ -13,6 +20,44 @@ const availableLangs = { ] }; +/* + * List of certifications with localization enabled in their world language. + * + * These certifications have been approved 100% on Crowdin at least during + * their launch, and hence meet the QA standard to be published live. Other + * certifications which have not been audited & approved will fallback to + * English equivalent. + */ +const auditedCerts = { + espanol: [ + 'responsive-web-design', + 'javascript-algorithms-and-data-structures' + ], + chinese: [ + 'responsive-web-design', + 'javascript-algorithms-and-data-structures', + 'front-end-libraries', + 'data-visualization', + 'apis-and-microservices', + 'quality-assurance' + ], + 'chinese-traditional': [ + 'responsive-web-design', + 'javascript-algorithms-and-data-structures', + 'front-end-libraries', + 'data-visualization', + 'apis-and-microservices', + 'quality-assurance' + ], + italian: [ + 'responsive-web-design', + 'javascript-algorithms-and-data-structures' + ], + portuguese: ['responsive-web-design'] +}; + +// --------------------------------------------------------------------------- + // Each client language needs an entry in the rest of the variables below /* These strings set the i18next language. It needs to be the two character @@ -55,3 +100,4 @@ exports.availableLangs = availableLangs; exports.i18nextCodes = i18nextCodes; exports.langDisplayNames = langDisplayNames; exports.langCodes = langCodes; +exports.auditedCerts = auditedCerts; diff --git a/curriculum/getChallenges.js b/curriculum/getChallenges.js index be8b327c08..3980b90380 100644 --- a/curriculum/getChallenges.js +++ b/curriculum/getChallenges.js @@ -11,7 +11,7 @@ const { } = require('../tools/challenge-parser/translation-parser'); /* eslint-enable max-len*/ -const { isAuditedCert } = require('../config/is-audited'); +const { isAuditedCert } = require('../utils/is-audited'); const { dasherize } = require('../utils/slugs'); const { createPoly } = require('../utils/polyvinyl'); const { helpCategoryMap } = require('../client/utils/challengeTypes'); diff --git a/curriculum/test/test-challenges.js b/curriculum/test/test-challenges.js index 400fe6fb95..2ca81404b3 100644 --- a/curriculum/test/test-challenges.js +++ b/curriculum/test/test-challenges.js @@ -2,7 +2,7 @@ const path = require('path'); const liveServer = require('live-server'); const stringSimilarity = require('string-similarity'); -const { isAuditedCert } = require('../../config/is-audited'); +const { isAuditedCert } = require('../../utils/is-audited'); const spinner = require('ora')(); diff --git a/config/is-audited.js b/utils/is-audited.js similarity index 53% rename from config/is-audited.js rename to utils/is-audited.js index e162bcc7a8..95d9d3b44a 100644 --- a/config/is-audited.js +++ b/utils/is-audited.js @@ -9,32 +9,7 @@ // translated, but when they are they can be included by adding 'certificates' // to the arrays below -const auditedCerts = { - espanol: [ - 'responsive-web-design', - 'javascript-algorithms-and-data-structures' - ], - chinese: [ - 'responsive-web-design', - 'javascript-algorithms-and-data-structures', - 'front-end-libraries', - 'data-visualization', - 'apis-and-microservices', - 'quality-assurance' - ], - 'chinese-traditional': [ - 'responsive-web-design', - 'javascript-algorithms-and-data-structures', - 'front-end-libraries', - 'data-visualization', - 'apis-and-microservices', - 'quality-assurance' - ], - italian: [ - 'responsive-web-design', - 'javascript-algorithms-and-data-structures' - ] -}; +const { auditedCerts } = require('../config/i18n/all-langs'); function isAuditedCert(lang, cert) { if (!lang || !cert)