diff --git a/modules/admin.js b/modules/admin.js index 678e707..bed5c95 100644 --- a/modules/admin.js +++ b/modules/admin.js @@ -25,7 +25,7 @@ var adminCommands = function(dbot) { child = exec("git pull", function (error, stdout, stderr) { console.log(stderr); - dbot.say(data.channel, 'Git pulled that shit.'); + dbot.say(data.channel, dbot.strings[dbot.language].gpull); commands.reload(data, params); }.bind(this)); }, @@ -33,7 +33,7 @@ var adminCommands = function(dbot) { 'reload': function(data, params) { dbot.db = JSON.parse(fs.readFileSync('db.json', 'utf-8')); dbot.reloadModules(); - dbot.say(data.channel, 'Reloaded that shit.'); + dbot.say(data.channel, dbot.strings[dbot.language].reload); }, 'say': function(data, params) { @@ -59,7 +59,7 @@ var adminCommands = function(dbot) { 'load': function(data, params) { dbot.moduleNames.push(params[1]); dbot.reloadModules(); - dbot.say(data.channel, 'Loaded new module: ' + params[1]); + dbot.say(data.channel, dbot.strings[dbot.language].load_module + params[1]); }, 'unload': function(data, params) { @@ -71,9 +71,9 @@ var adminCommands = function(dbot) { dbot.moduleNames.splice(moduleIndex, 1); dbot.reloadModules(); - dbot.say(data.channel, 'Turned off module: ' + params[1]); + dbot.say(data.channel, dbot.strings[dbot.language].unload_module + params[1]); } else { - dbot.say(data.channel, 'Module ' + params[1] + ' isn\'t loaded... Idiot...'); + dbot.say(data.channel, params[1] + dbot.strings[dbot.language].unload_error); } }, @@ -83,31 +83,31 @@ var adminCommands = function(dbot) { } else { dbot.db.bans[params[2]] = [ params[1] ]; } - dbot.say(data.channel, params[1] + ' banned from ' + params[2]); + dbot.say(data.channel, params[1] + dbot.strings[dbot.language].banned + params[2]); }, 'unban': function(data, params) { if(dbot.db.bans.hasOwnProperty(params[2]) && dbot.db.bans[params[2]].include(params[1])) { dbot.db.bans[params[2]].splice(dbot.db.bans[params[2]].indexOf(params[1]), 1); - dbot.say(data.channel, params[1] + ' unbanned from ' + params[2]); + dbot.say(data.channel, params[1] + dbot.strings[dbot.language].unbanned + params[2]); } else { - dbot.say(data.channel, 'It appears ' + params[1] + 'wasn\'t banned from that command, you fool.'); + dbot.say(data.channel, params[1] + dbot.strings[dbot.language].unban_error); } }, 'modehate': function(data, params) { dbot.db.modehate.push(params[1]); - dbot.say(data.channel, 'Now modehating on ' + params[1]); + dbot.say(data.channel, dbot.strings[dbot.language].modehate + params[1]); }, 'unmodehate': function(data, params) { dbot.db.modehate.splice(dbot.db.modehate.indexOf(params[1]), 1); - dbot.say(data.channel, 'No longer modehating on ' + params[1]); + dbot.say(data.channel, dbot.strings[dbot.language].unmodehate + params[1]); }, 'lock': function(data, params) { dbot.db.locks.push(params[1]); - dbot.say(data.channel, 'Locked ' + params[1] + ' quotes.'); + dbot.say(data.channel, dbot.strings[dbot.language].qlock + params[1]); } }; diff --git a/modules/quotes.js b/modules/quotes.js index d5f9670..069e532 100644 --- a/modules/quotes.js +++ b/modules/quotes.js @@ -53,7 +53,7 @@ var quotes = function(dbot) { if(quotes.hasOwnProperty(key)) { dbot.say(data.channel, q[1] + ': ' + interpolatedQuote(key)); } else { - dbot.say(data.channel, 'Nobody loves ' + q[1]); + dbot.say(data.channel, dbot.strings[dbot.language].category_not_found + q[1]); } } }, @@ -70,7 +70,7 @@ var quotes = function(dbot) { qSizes = qSizes.sort(function(a, b) { return a[1] - b[1]; }); qSizes = qSizes.slice(qSizes.length - 10).reverse(); - var qString = "Largest categories: "; + var qString = dbot.strings[dbot.language].large_categories; for(var i=0;i 0) { - dbot.say(data.channel, "Pruning empty quote categories: " + pruned.join(", ")); + dbot.say(data.channel, dbot.strings[dbot.language].prune + pruned.join(", ")); } else { - dbot.say(data.channel, "No empty quote categories. Commence incineration."); + dbot.say(data.channel, dbot.strings[dbot.language].no_prune); } } }; diff --git a/modules/spelling.js b/modules/spelling.js index 5ce2605..1aee79c 100644 --- a/modules/spelling.js +++ b/modules/spelling.js @@ -42,11 +42,12 @@ var spelling = function(dbot) { var otherQ = data.message.valMatch(/^([\d\w\s]*): (?:\*\*?([\d\w\s']*)|([\d\w\s']*)\*\*?)$/, 4); if(q) { correct(data, q[1] || q[2], data.user, function (e) { - dbot.say(data.channel, e.correcter + ' meant: ' + e.fix); + dbot.say(data.channel, e.correcter + dbot.strings[dbot.language].spelling_self + e.fix); }); } else if(otherQ) { correct(data, otherQ[2] || otherQ[3], otherQ[1], function (e) { - dbot.say(data.channel, e.correcter + ' thinks ' + e.candidate + ' meant: ' + e.fix); + dbot.say(data.channel, e.correcter + dbot.strings[dbot.language].spelling_other + + e.candidate + dbot.strings[dbot.language].spelling_self + e.fix); }); } else { if(last.hasOwnProperty(data.channel)) { diff --git a/run.js b/run.js index b8e8d74..83d2fdc 100644 --- a/run.js +++ b/run.js @@ -39,6 +39,9 @@ var DBot = function(timers) { if(!this.db.hasOwnProperty("locks")) { this.db.locks = []; } + + // Load the strings file + this.strings = fs.readFileSync('strings.json', 'utf-8'); // Populate bot properties with config data this.name = this.config.name || 'dbox'; @@ -49,6 +52,7 @@ var DBot = function(timers) { this.port = this.config.port || 6667; this.webPort = this.config.webPort || 443; this.moduleNames = this.config.modules || [ 'command', 'js', 'admin', 'kick', 'modehate', 'quotes', 'puns', 'spelling', 'web', 'youare' ]; + this.language = this.config.language || 'english'; this.sessionData = {}; this.timers = timers.create(); @@ -113,7 +117,7 @@ DBot.prototype.reloadModules = function() { try { this.rawModules.push(require('./modules/' + name)); } catch(err) { - console.log('Failed to load module: ' + name); + console.log(this.strings[this.language].module_load_error + name); } }.bind(this)); diff --git a/strings.json b/strings.json index 656a892..e24da9a 100644 --- a/strings.json +++ b/strings.json @@ -26,13 +26,14 @@ "load_module": "Loaded new module: ", "unload_module": "Turned off module: ", "unload_error": " isn't loaded. Idiot.", + "banned": " banned from ", + "unbanned": " unbanned from ", "unban_error": " wasn't banned from that command, fool.", "modehate": "Hating on ", "unmodehate": "No longer hating on ", "qlock": "Locked quote category: ", "spelling_self": " meant: ", - "spelling_other_1": " thinks ", - "spelling_other_2": " meant:" + "spelling_other": " thinks ", }, "spanish": { @@ -62,6 +63,8 @@ "load_module": "", "unload_module": "", "unload_error": "", + "banned": "", + "unbanned": "", "unban_error": ".", "modehate": "", "unmodehate": "",