fix(learn): use json files for comments (#40844)

This commit is contained in:
Randell Dawson
2021-01-31 09:06:57 -07:00
committed by GitHub
parent 81e55605a2
commit 00a876d9b2
14 changed files with 1397 additions and 1439 deletions

View File

@ -32,10 +32,10 @@ const COMMENT_TRANSLATIONS = createCommentMap(
);
function getTranslatableComments(dictionariesDir) {
const { COMMENTS_TO_TRANSLATE } = require(path.resolve(
const COMMENTS_TO_TRANSLATE = require(path.resolve(
dictionariesDir,
'english',
'comments'
'comments.json'
));
return COMMENTS_TO_TRANSLATE.map(({ text }) => text);
}
@ -52,16 +52,23 @@ function createCommentMap(dictionariesDir) {
const dictionaries = languages.reduce(
(acc, lang) => ({
...acc,
[lang]: require(path.resolve(dictionariesDir, lang, 'comments'))
[lang]: require(path.resolve(dictionariesDir, lang, 'comments.json'))
}),
{}
);
// get the english dicts
const {
COMMENTS_TO_TRANSLATE,
COMMENTS_TO_NOT_TRANSLATE
} = require(path.resolve(dictionariesDir, 'english', 'comments'));
const COMMENTS_TO_TRANSLATE = require(path.resolve(
dictionariesDir,
'english',
'comments.json'
));
const { COMMENTS_TO_NOT_TRANSLATE } = require(path.resolve(
dictionariesDir,
'english',
'comments-to-not-translate'
));
// map from english comment text to translations
const translatedCommentMap = COMMENTS_TO_TRANSLATE.reduce(