docs: update guide url
This commit is contained in:
17
curriculum/challenges/adddir.js
Normal file
17
curriculum/challenges/adddir.js
Normal file
@ -0,0 +1,17 @@
|
||||
var fs = require('fs');
|
||||
|
||||
var directory = '';
|
||||
// Get list of .md files in current directory
|
||||
fs.readdirSync('./english').forEach(file1 => {
|
||||
if (file1 != '.DS_Store') {
|
||||
directory = './spanish/' + file1;
|
||||
!fs.existsSync(directory) && fs.mkdirSync(directory);
|
||||
fs.readdirSync('./english/' + file1).forEach(file2 => {
|
||||
if (file2 != '.DS_Store') {
|
||||
directory = './spanish/' + file1 + '/' + file2;
|
||||
!fs.existsSync(directory) && fs.mkdirSync(directory);
|
||||
console.log(file2);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -3,7 +3,7 @@ id: 587d774c367417b2b2512a9c
|
||||
title: Add a Text Alternative to Images for Visually Impaired Accessibility
|
||||
challengeType: 0
|
||||
videoUrl: 'https://scrimba.com/c/cPp7VfD'
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/add-alt-text-to-an-image-for-accessibility'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/add-alt-text-to-an-image-for-accessibility'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: bad87fee1348bd9aedf08823
|
||||
title: Add a Negative Margin to an Element
|
||||
challengeType: 0
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/add-a-negative-margin-to-an-element'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/add-a-negative-margin-to-an-element'
|
||||
videoUrl: 'https://scrimba.com/c/cnpyGs3'
|
||||
---
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: bad87fee1348bd9bedf08813
|
||||
title: Add Borders Around Your Elements
|
||||
challengeType: 0
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/add-borders-around-your-elements'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/add-borders-around-your-elements'
|
||||
videoUrl: 'https://scrimba.com/c/c2MvnHZ'
|
||||
---
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: bad87fee1348bd9aedf08824
|
||||
title: Add Different Padding to Each Side of an Element
|
||||
challengeType: 0
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/add-different-padding-to-each-side-of-an-element'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/add-different-padding-to-each-side-of-an-element'
|
||||
videoUrl: 'https://scrimba.com/c/cB7mwUw'
|
||||
---
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: bad87fee1348bd9aedf08814
|
||||
title: Add Rounded Corners with border-radius
|
||||
challengeType: 0
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/add-rounded-corners-a-border-radius'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/add-rounded-corners-a-border-radius'
|
||||
videoUrl: 'https://scrimba.com/c/cbZm2hg'
|
||||
---
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: bad87fee1348bd9aedf08822
|
||||
title: Adjust the Margin of an Element
|
||||
challengeType: 0
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/adjust-the-margin-of-an-element'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/adjust-the-margin-of-an-element'
|
||||
videoUrl: 'https://scrimba.com/c/cVJarHW'
|
||||
---
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: bad88fee1348bd9aedf08825
|
||||
title: Adjust the Padding of an Element
|
||||
challengeType: 0
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/adjust-the-padding-of-an-element'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/adjust-the-padding-of-an-element'
|
||||
videoUrl: 'https://scrimba.com/c/cED8ZC2'
|
||||
---
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: bad87fee1348bd9aedd08830
|
||||
title: Add a Submit Button to a Form
|
||||
challengeType: 0
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/add-a-submit-button-to-a-form'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/add-a-submit-button-to-a-form'
|
||||
videoUrl: 'https://scrimba.com/p/pVMPUv/cp2Nkhz'
|
||||
---
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: bad87fee1348bd9aedf08812
|
||||
title: Add Images to Your Website
|
||||
challengeType: 0
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/add-images-to-your-website'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/add-images-to-your-website'
|
||||
videoUrl: 'https://scrimba.com/p/pVMPUv/c8EbJf2'
|
||||
---
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: bad87fee1348bd9aedf08830
|
||||
title: Add Placeholder Text to a Text Field
|
||||
challengeType: 0
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/add-placeholder-text-to-a-text-field'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/add-placeholder-text-to-a-text-field'
|
||||
videoUrl: 'https://scrimba.com/p/pVMPUv/cKdJDhg'
|
||||
---
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: 56bbb991ad1ed5201cd392ca
|
||||
title: Access Array Data with Indexes
|
||||
challengeType: 1
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/access-array-data-with-indexes'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/access-array-data-with-indexes'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: 56592a60ddddeae28f7aa8e1
|
||||
title: Access Multi-Dimensional Arrays With Indexes
|
||||
challengeType: 1
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/access-array-data-with-indexes'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/access-array-data-with-indexes'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: 56533eb9ac21ba0edf2244cd
|
||||
title: Accessing Nested Arrays
|
||||
challengeType: 1
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/access-array-data-with-indexes'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/access-array-data-with-indexes'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: 56533eb9ac21ba0edf2244cc
|
||||
title: Accessing Nested Objects
|
||||
challengeType: 1
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/accessing-nested-objects-in-json'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/accessing-nested-objects-in-json'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: 56533eb9ac21ba0edf2244c8
|
||||
title: Accessing Object Properties with Bracket Notation
|
||||
challengeType: 1
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/accessing-objects-properties-with-bracket-notation'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/accessing-objects-properties-with-bracket-notation'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: 56533eb9ac21ba0edf2244c9
|
||||
title: Accessing Object Properties with Variables
|
||||
challengeType: 1
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/accessing-objects-properties-with-variables'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/accessing-objects-properties-with-variables'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: 56533eb9ac21ba0edf2244de
|
||||
title: Adding a Default Option in Switch Statements
|
||||
challengeType: 1
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/adding-a-default-option-in-switch-statements'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/adding-a-default-option-in-switch-statements'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: 56533eb9ac21ba0edf2244ed
|
||||
title: Appending Variables to Strings
|
||||
challengeType: 1
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/appending-variables-to-strings'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/appending-variables-to-strings'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: 56533eb9ac21ba0edf2244c3
|
||||
title: Assignment with a Returned Value
|
||||
challengeType: 1
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/assignment-with-a-returned-value'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/assignment-with-a-returned-value'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -3,7 +3,7 @@ id: a97fd23d9b809dac9921074f
|
||||
title: Arguments Optional
|
||||
isRequired: true
|
||||
challengeType: 5
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/arguments-optional'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/arguments-optional'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
@ -2,7 +2,7 @@
|
||||
id: bad87fee1348bd9aec908850
|
||||
title: Apply the Default Bootstrap Button Style
|
||||
challengeType: 0
|
||||
guideUrl: 'https://guide.freecodecamp.org/certificates/apply-the-default-bootstrap-button-style'
|
||||
guideUrl: 'https://www.freecodecamp.org/guide/certificates/apply-the-default-bootstrap-button-style'
|
||||
---
|
||||
|
||||
## Description
|
||||
|
153
curriculum/challenges/translatemd.js
Normal file
153
curriculum/challenges/translatemd.js
Normal file
@ -0,0 +1,153 @@
|
||||
var fs = require('fs');
|
||||
|
||||
var lang = 'es';
|
||||
var langFull = 'spanish';
|
||||
|
||||
// Get list of .md files in current directory
|
||||
// fs.readdirSync(dir).forEach(file => {
|
||||
// if (file.includes('.md')) {getFile(file)}
|
||||
// });
|
||||
|
||||
fs.readdirSync('./english').forEach(file1 => {
|
||||
if (file1 != '.DS_Store') {
|
||||
fs.readdirSync('./english/' + file1).forEach(file2 => {
|
||||
if (file2 != '.DS_Store') {
|
||||
var dir = '/' + file1 + '/' + file2;
|
||||
fs.readdirSync('./english' + dir).forEach(file => {
|
||||
if (file.includes('.md') && dir) {
|
||||
getFile(file, dir);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Load in full text, description, instructions, and title
|
||||
function getFile(file, dir) {
|
||||
let originalFileName = './english/' + dir + '/' + file;
|
||||
let fileString = fs.readFileSync(originalFileName).toString();
|
||||
|
||||
// Add 'notranslate' class to code so Google Translate API will not translate code segments.
|
||||
fileString = fileString.replace(/<code>/g, '<code class="notranslate">');
|
||||
fileString = fileString.replace(
|
||||
/<blockquote>/g,
|
||||
'<blockquote class="notranslate">'
|
||||
);
|
||||
fileString = fileString.replace(/^.*videoUrl.*$/gm, "videoUrl: ''");
|
||||
fileString = fileString.replace(
|
||||
/https:\/\/www\.freecodecamp\.org/,
|
||||
'https://' + langFull + '.freecodecamp.org'
|
||||
);
|
||||
let description = fileString.match(
|
||||
/<section id='description'>(.|\n)*?<\/section>/
|
||||
)[0];
|
||||
description = description.replace(/\r?\n/g, '<code>0</code>');
|
||||
let instructions = fileString.match(
|
||||
/<section id='instructions'>(.|\n)*?<\/section>/
|
||||
)[0];
|
||||
instructions = instructions.replace(/\r?\n/g, '<code>0</code>');
|
||||
let tests = fileString.match(/<section id='tests'>(.|\n)*?<\/section>/)[0];
|
||||
let title = fileString.split('\n')[2].split(': ')[1];
|
||||
processFile(fileString, description, instructions, tests, title, file, dir);
|
||||
}
|
||||
|
||||
// Get translatins from Google Translate API and insert into file
|
||||
function processFile(
|
||||
fileString,
|
||||
description,
|
||||
instructions,
|
||||
tests,
|
||||
title,
|
||||
file,
|
||||
dir
|
||||
) {
|
||||
// const translateText = (text, target) => {
|
||||
// return new Promise((resolve, reject) => {
|
||||
// // Imports the Google Cloud client library
|
||||
// const {Translate} = require('@google-cloud/translate');
|
||||
|
||||
// // Creates a client
|
||||
// const translate = new Translate();
|
||||
|
||||
// translate
|
||||
// .translate(text, target)
|
||||
// .then(results => {
|
||||
// let translations = results[0];
|
||||
// translations = Array.isArray(translations)
|
||||
// ? translations
|
||||
// : [translations];
|
||||
// resolve(translations);
|
||||
// })
|
||||
// .catch(err => {
|
||||
// reject(console.log("Error"));
|
||||
// if (err) {}
|
||||
// });
|
||||
// });
|
||||
// };
|
||||
|
||||
const translateText = (text, target) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(['translated', 'translated', 'translated', 'translated']);
|
||||
});
|
||||
};
|
||||
|
||||
const translateTests = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
let testsArray = tests.split('\n');
|
||||
let testsToTranslate = [];
|
||||
|
||||
testsArray.forEach((test, index) => {
|
||||
if (test.includes('- text: ')) {
|
||||
testsToTranslate.push(test.slice(8));
|
||||
}
|
||||
});
|
||||
translateText(testsToTranslate, lang).then(translation => {
|
||||
let transIndex = 0;
|
||||
testsArray.forEach((test, index) => {
|
||||
if (test.includes('- text')) {
|
||||
testsArray[index] = '- text' + translation[transIndex];
|
||||
transIndex++;
|
||||
}
|
||||
});
|
||||
resolve(testsArray.join('\n'));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Promise.all([
|
||||
translateText(description, lang),
|
||||
translateText(instructions, lang),
|
||||
translateText(title, lang),
|
||||
translateTests(tests, lang)
|
||||
]).then(function(translations) {
|
||||
// Replace English with translation
|
||||
fileString = fileString.replace(
|
||||
/<section id='description'>(.|\n)*?<\/section>/,
|
||||
translations[0][0].replace(/<code>0<\/code> /g, '\n')
|
||||
);
|
||||
fileString = fileString.replace(
|
||||
/<section id='instructions'>(.|\n)*?<\/section>/,
|
||||
translations[1][0].replace(/<code>0<\/code> /g, '\n')
|
||||
);
|
||||
fileString = fileString.replace(
|
||||
title,
|
||||
title + '\nlocaleTitle: ' + translations[2]
|
||||
);
|
||||
fileString = fileString.replace(
|
||||
/<section id='tests'>(.|\n)*?<\/section>/,
|
||||
translations[3]
|
||||
);
|
||||
fileString = fileString.replace(/ class=\"notranslate\"/g, ''); // remove 'notranslate' class
|
||||
writeFile(fileString, file, dir);
|
||||
});
|
||||
}
|
||||
|
||||
function writeFile(fileString, file, dir) {
|
||||
let fullFileName =
|
||||
'.' + '/' + langFull + dir + '/' + file.slice(0, -10) + langFull + '.md';
|
||||
fs.writeFile(fullFileName, fileString, function(err) {
|
||||
if (err) throw err;
|
||||
console.log('Saved!');
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user