fix(tools): update parser for multi-file editor
parent
a500279036
commit
7bed07ee8a
|
@ -113,17 +113,12 @@ async function buildCurriculum(file, curriculum) {
|
||||||
async function parseTranslation(engPath, transPath, dict) {
|
async function parseTranslation(engPath, transPath, dict) {
|
||||||
const engChal = await parseMarkdown(engPath);
|
const engChal = await parseMarkdown(engPath);
|
||||||
const translatedChal = await parseMarkdown(transPath);
|
const translatedChal = await parseMarkdown(transPath);
|
||||||
const codeLang =
|
|
||||||
engChal.files && engChal.files[0] ? engChal.files[0].ext : null;
|
|
||||||
|
|
||||||
const engWithTranslatedComments = codeLang
|
const engWithTranslatedComments = translateCommentsInChallenge(
|
||||||
? translateCommentsInChallenge(
|
|
||||||
engChal,
|
engChal,
|
||||||
getChallengeLang(transPath),
|
getChallengeLang(transPath),
|
||||||
dict,
|
dict
|
||||||
codeLang
|
);
|
||||||
)
|
|
||||||
: engChal;
|
|
||||||
return mergeChallenges(engWithTranslatedComments, translatedChal);
|
return mergeChallenges(engWithTranslatedComments, translatedChal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,17 +15,19 @@ exports.translateComments = (text, lang, dict, codeLang) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.translateCommentsInChallenge = (challenge, lang, dict, codeLang) => {
|
exports.translateCommentsInChallenge = (challenge, lang, dict) => {
|
||||||
const challClone = clone(challenge);
|
const challClone = clone(challenge);
|
||||||
|
|
||||||
if (challClone.files[0] && challClone.files[0].contents) {
|
Object.keys(challClone.files).forEach(key => {
|
||||||
challClone.files[0].contents = this.translateComments(
|
if (challClone.files[key].contents) {
|
||||||
challenge.files[0].contents,
|
challClone.files[key].contents = this.translateComments(
|
||||||
|
challenge.files[key].contents,
|
||||||
lang,
|
lang,
|
||||||
dict,
|
dict,
|
||||||
codeLang
|
challClone.files[key].ext
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return challClone;
|
return challClone;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue