feat: restrict translation to audited certs
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
1ec6cf1efd
commit
b197f73881
@ -12,6 +12,7 @@ const {
|
||||
const { COMMENT_TRANSLATIONS } = require('./comment-dictionary');
|
||||
|
||||
const { dasherize } = require('../utils/slugs');
|
||||
const { isAuditedCert } = require('../utils/is-audited');
|
||||
|
||||
const challengesDir = path.resolve(__dirname, './challenges');
|
||||
const metaDir = path.resolve(challengesDir, '_meta');
|
||||
@ -121,10 +122,17 @@ async function createChallenge(fullPath, maybeMeta) {
|
||||
meta = require(metaPath);
|
||||
}
|
||||
const { name: superBlock } = superBlockInfoFromFullPath(fullPath);
|
||||
if (!isAcceptedLanguage(getChallengeLang(fullPath)))
|
||||
throw Error(`${getChallengeLang(fullPath)} is not a accepted language.
|
||||
const lang = getChallengeLang(fullPath);
|
||||
if (!isAcceptedLanguage(lang))
|
||||
throw Error(`${lang} is not a accepted language.
|
||||
Trying to parse ${fullPath}`);
|
||||
const challenge = await (isEnglishChallenge(fullPath)
|
||||
// assumes superblock names are unique
|
||||
// while the auditing is ongoing, we default to English for un-audited certs
|
||||
// once that's complete, we can revert to using isEnglishChallenge(fullPath)
|
||||
const isEnglish =
|
||||
isEnglishChallenge(fullPath) || !isAuditedCert(lang, superBlock);
|
||||
if (isEnglish) fullPath = getEnglishPath(fullPath);
|
||||
const challenge = await (isEnglish
|
||||
? parseMarkdown(fullPath)
|
||||
: parseTranslation(
|
||||
getEnglishPath(fullPath),
|
||||
|
15
utils/is-audited.js
Normal file
15
utils/is-audited.js
Normal file
@ -0,0 +1,15 @@
|
||||
// this can go once all certs have been audited.
|
||||
function isAuditedCert(lang, cert) {
|
||||
if (!lang || !cert)
|
||||
throw Error('Both arguments must be provided for auditing');
|
||||
// in order to see the challenges in the client, add the certification that
|
||||
// contains those challenges to this array:
|
||||
const auditedCerts = [
|
||||
'responsive-web-design',
|
||||
'javascript-algorithms-and-data-structures',
|
||||
'certificates'
|
||||
];
|
||||
return lang === 'english' || auditedCerts.includes(cert);
|
||||
}
|
||||
|
||||
exports.isAuditedCert = isAuditedCert;
|
Reference in New Issue
Block a user