Skip to content

Commit 14417ed

Browse files
Added basic i18n support
1 parent cfca126 commit 14417ed

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

problem.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ module.exports = function createProblem(dirname) {
88
var problemName = dirname.split(path.sep);
99
problemName = problemName[problemName.length-1];
1010

11-
exports.problem = getFile(path.join(dirname, 'problem.md'));
12-
exports.solution = getFile(path.join(dirname, 'solution.md'));
13-
14-
var solutionPath = path.resolve(dirname, "../../solutions", problemName, "index.js");
15-
var troubleshootingPath = path.join(dirname, '../../troubleshooting.md');
11+
exports.init = function (workshopper) {
12+
var postfix = workshopper.lang === 'en' ? '' : '_' + workshopper.lang;
13+
this.problem = getFile(path.join(dirname, 'problem' + postfix + '.md'));
14+
this.solution = getFile(path.join(dirname, 'solution' + postfix + '.md'));
15+
this.solutionPath = path.resolve(dirname, "../../solutions", problemName, "index.js");
16+
this.troubleshootingPath = path.join(dirname, '../../troubleshooting' + postfix + '.md');
17+
}
1618

1719
exports.verify = function (args, cb) {
1820

1921
var attemptPath = path.resolve(process.cwd(), args[0]);
20-
compare(solutionPath, attemptPath, function(match, obj) {
22+
compare(this.solutionPath, attemptPath, function(match, obj) {
2123

2224
if(match) {
2325
return cb(true);
@@ -28,7 +30,7 @@ module.exports = function createProblem(dirname) {
2830
return;
2931
}
3032

31-
var message = getFile(troubleshootingPath);
33+
var message = getFile(this.troubleshootingPath);
3234

3335
message = message.replace(/%solution%/g, obj.solution);
3436
message = message.replace(/%attempt%/g, obj.attempt);
@@ -39,7 +41,7 @@ module.exports = function createProblem(dirname) {
3941

4042
cb(false);
4143

42-
});
44+
}.bind(this));
4345
};
4446

4547
exports.run = function (args) {

0 commit comments

Comments
 (0)