mirror of
https://github.com/reality/dbot.git
synced 2024-11-23 20:39:25 +01:00
Switched key of strings object so that there's only one object and it's easier to read and therefore translate. Created 't' function to translate strings, changed quotes module to this format. Need to change the others. Will now fall back to English if translation in given language is not available.
This commit is contained in:
parent
64fd389418
commit
42c4871a16
@ -54,7 +54,7 @@ var quotes = function(dbot) {
|
||||
if(quotes.hasOwnProperty(key)) {
|
||||
dbot.say(data.channel, q[1] + ': ' + interpolatedQuote(key));
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].category_not_found.format({'category': q[1]}));
|
||||
dbot.say(data.channel, dbot.t('category_not_found', {'category': q[1]}));
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -71,7 +71,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 = dbot.strings[dbot.language].large_categories;
|
||||
var qString = dbot.t('large_categories');
|
||||
|
||||
for(var i=0;i<qSizes.length;i++) {
|
||||
qString += qSizes[i][0] + " (" + qSizes[i][1] + "), ";
|
||||
@ -82,12 +82,12 @@ var quotes = function(dbot) {
|
||||
|
||||
'~qsearch': function(data, params) {
|
||||
if(params[2] === undefined) {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].syntax_error);
|
||||
dbot.say(data.channel, dbot.t('syntax_error'));
|
||||
} else {
|
||||
params[1].trim();
|
||||
key = params[1].toLowerCase();
|
||||
if(!quotes.hasOwnProperty(key)) {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].empty_category);
|
||||
dbot.say(data.channel, dbot.t('empty_category'));
|
||||
} else {
|
||||
var matches = [];
|
||||
|
||||
@ -98,7 +98,7 @@ var quotes = function(dbot) {
|
||||
}.bind(this));
|
||||
|
||||
if(matches.length == 0) {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].no_results);
|
||||
dbot.say(data.channel, dbot.t('no_results'));
|
||||
} else {
|
||||
dbot.say(data.channel, params[1] + ' (' + params[2] + '): ' + matches.random() + ' [' + matches.length + ' results]');
|
||||
}
|
||||
@ -120,12 +120,12 @@ var quotes = function(dbot) {
|
||||
}
|
||||
rmAllowed = false;
|
||||
dbot.say(data.channel, '\'' + quote + '\'' +
|
||||
dbot.strings[dbot.language].removed_from + q[1]);
|
||||
dbot.t('removed_from') + q[1]);
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].locked_category.format({'category': q[1]}));
|
||||
dbot.say(data.channel, dbot.t('locked_category', {'category': q[1]}));
|
||||
}
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].no_quotes.format({'category': q[1]}));
|
||||
dbot.say(data.channel, dbot.t('no_quotes', {'category': q[1]}));
|
||||
}
|
||||
} else {
|
||||
var last = addStack.pop();
|
||||
@ -133,16 +133,16 @@ var quotes = function(dbot) {
|
||||
if(!dbot.db.locks.include(last)) {
|
||||
quotes[last].pop();
|
||||
rmAllowed = false;
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].last_removed.format({'category': last}));
|
||||
dbot.say(data.channel, dbot.t('last_removed', {'category': last}));
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].locked_category.format({'category': last}));
|
||||
dbot.say(data.channel, dbot.t('locked_category', {'category': last}));
|
||||
}
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].no_recent_adds);
|
||||
dbot.say(data.channel, dbot.t('no_recent_adds'));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].rmlast_spam);
|
||||
dbot.say(data.channel, dbot.t('rmlast_spam'));
|
||||
}
|
||||
},
|
||||
|
||||
@ -159,21 +159,21 @@ var quotes = function(dbot) {
|
||||
delete quotes[q[1]];
|
||||
}
|
||||
rmAllowed = false;
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].removed_from.format({'category': q[1], 'quote': q[2]}));
|
||||
dbot.say(data.channel, dbot.t('removed_from', {'category': q[1], 'quote': q[2]}));
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].q_not_exist_under.format({'category': q[1], 'quote': q[2]}));
|
||||
dbot.say(data.channel, dbot.t('q_not_exist_under', {'category': q[1], 'quote': q[2]}));
|
||||
}
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].locked_category.format({'category': q[1]}));
|
||||
dbot.say(data.channel, dbot.t('locked_category', {'category': q[1]}));
|
||||
}
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].no_quotes.format({'category': q[1]}));
|
||||
dbot.say(data.channel, dbot.t('no_quotes', {'category': q[1]}));
|
||||
}
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].syntax_error);
|
||||
dbot.say(data.channel, dbot.t('syntax_error'));
|
||||
}
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].rmlast_spam);
|
||||
dbot.say(data.channel, dbot.t('rmlast_spam'));
|
||||
}
|
||||
},
|
||||
|
||||
@ -183,16 +183,16 @@ var quotes = function(dbot) {
|
||||
q[1] = q[1].trim();
|
||||
key = q[1].toLowerCase();
|
||||
if(quotes.hasOwnProperty(key)) {
|
||||
dbot.say(data.channel, q[1] + ' has ' + quotes[key].length + ' quotes.');
|
||||
dbot.say(data.channel, dbot.t('quote_count', {'category': q[1], 'count': quotes[key].length}));
|
||||
} else {
|
||||
dbot.say(data.channel, 'No quotes under ' + q[1]);
|
||||
dbot.say(data.channel, dbot.t('no_quotes', {'category': q[1]}));
|
||||
}
|
||||
} else { // Give total quote count
|
||||
var totalQuoteCount = 0;
|
||||
for(var category in quotes) {
|
||||
totalQuoteCount += category.length;
|
||||
}
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].total_quotes.format({'count': totalQuoteCount}));
|
||||
dbot.say(data.channel, dbot.t('total_quotes', {'count': totalQuoteCount}));
|
||||
}
|
||||
},
|
||||
|
||||
@ -204,16 +204,16 @@ var quotes = function(dbot) {
|
||||
quotes[key] = [];
|
||||
} else {
|
||||
if (quotes[key].include(q[2])) {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].quote_exists);
|
||||
dbot.say(data.channel, dbot.t('quote_exists'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
quotes[key].push(q[2]);
|
||||
addStack.push(q[1]);
|
||||
rmAllowed = true;
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].quote_saved.format({'category': q[1], 'count': quotes[key].length}));
|
||||
dbot.say(data.channel, dbot.t('quote_saved', {'category': q[1], 'count': quotes[key].length}));
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].syntax_error);
|
||||
dbot.say(data.channel, dbot.t('syntax_error'));
|
||||
}
|
||||
},
|
||||
|
||||
@ -225,9 +225,9 @@ var quotes = function(dbot) {
|
||||
if(!quotes.hasOwnProperty(key) || (quotes.hasOwnProperty(key) &&
|
||||
quotes[key].length == 1)) {
|
||||
quotes[key] = [q[2]];
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].quote_saved.format({'category': q[1], 'count': 1}));
|
||||
dbot.say(data.channel, dbot.t('quote_saved', {'category': q[1], 'count': 1}));
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].quote_replace);
|
||||
dbot.say(data.channel, dbot.t('quote_replace'));
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -243,9 +243,10 @@ var quotes = function(dbot) {
|
||||
|
||||
'~link': function(data, params) {
|
||||
if(params[1] === undefined || !quotes.hasOwnProperty(params[1].toLowerCase())) {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].syntax_error);
|
||||
dbot.say(data.channel, dbot.t('syntax_error'));
|
||||
} else {
|
||||
dbot.say(data.channel, 'Link to "'+params[1]+'" - http://nc.no.de:443/quotes/'+params[1]);
|
||||
dbot.say(data.channel, dbot.t('quote_link', {'category': params[1]}) +
|
||||
' - http://nc.no.de:443/quotes/' + params[1]);
|
||||
}
|
||||
},
|
||||
|
||||
@ -260,9 +261,9 @@ var quotes = function(dbot) {
|
||||
}
|
||||
}
|
||||
if(pruned.length > 0) {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].prune.format({'categories': pruned.join(", ")}));
|
||||
dbot.say(data.channel, dbot.t('prune', {'categories': pruned.join(", ")}));
|
||||
} else {
|
||||
dbot.say(data.channel, dbot.strings[dbot.language].no_prune);
|
||||
dbot.say(data.channel, dbot.t('no_prune'));
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -289,7 +290,7 @@ var quotes = function(dbot) {
|
||||
if((dbot.db.bans.hasOwnProperty('~qadd') &&
|
||||
dbot.db.bans['~qadd'].include(data.user)) ||
|
||||
dbot.db.bans['*'].include(data.user)) {
|
||||
dbot.say(data.channel, data.user + ' is banned from using this command. Commence incineration.');
|
||||
dbot.say(data.channel, dbot.t('command_ban', {'user': data.user}));
|
||||
} else {
|
||||
if(!dbot.db.quoteArrs.hasOwnProperty('realityonce')) {
|
||||
dbot.db.quoteArrs['realityonce'] = [];
|
||||
|
10
run.js
10
run.js
@ -78,6 +78,16 @@ DBot.prototype.say = function(channel, data) {
|
||||
this.instance.say(channel, data);
|
||||
};
|
||||
|
||||
// Format given stored string in config language
|
||||
DBot.prototype.t = function(string, formatData) {
|
||||
var lang = this.language;
|
||||
if(!this.strings[string].hasOwnProperty(lang)) {
|
||||
lang = "english";
|
||||
}
|
||||
|
||||
return this.strings[string][lang].format(formatData);
|
||||
};
|
||||
|
||||
DBot.prototype.act = function(channel, data) {
|
||||
this.instance.send('PRIVMSG', channel, ':\001ACTION ' + data + '\001');
|
||||
}
|
||||
|
210
strings.json
210
strings.json
@ -1,74 +1,144 @@
|
||||
{
|
||||
"english": {
|
||||
"syntax_error": "Invalid syntax. Initiate incineration.",
|
||||
"module_load_error": "Failed to load module: {moduleName}",
|
||||
"category_not_found": "Nobody loves {category}",
|
||||
"large_categories": "Largest categories: ",
|
||||
"empty_category": "That category has no quotes in. Commence incineration.",
|
||||
"no_results": "No results found.",
|
||||
"locked_category": "{category} is locked. Commence incineration.",
|
||||
"no_quotes": "No quotes exist under {category}",
|
||||
"last_removed": "Last quote removed from {category}.",
|
||||
"no_recent_adds": "No quotes were added recently.",
|
||||
"rmlast_spam": "No spamming that shit. Try again in a few minutes...",
|
||||
"removed_from": "'{quote}' removed from {category}",
|
||||
"q_not_exist_under": "'{quote}' doesn't exist under '{category}'.",
|
||||
"total_quotes": "Total quote count: {count}.",
|
||||
"quote_exists": "Quote already in DB. Initiate incineration.",
|
||||
"quote_saved": "Quote saved in '{category}' ({count}).",
|
||||
"quote_replace": "No replacing arrays, you whore.",
|
||||
"prune": "Pruning empty quote categories: {categories}",
|
||||
"no_prune": "No empty quote categories. Commence incineration.",
|
||||
"command_ban": " is banned from using this command. Commence incineration.",
|
||||
"correction": "Did you mean: ",
|
||||
"gpull": "Git pulled that shit.",
|
||||
"reload": "Reloaded that shit.",
|
||||
"load_module": "Loaded new module: {moduleName}",
|
||||
"unload_module": "Turned off module: {moduleName}",
|
||||
"unload_error": "{moduleName} isn't loaded. Idiot.",
|
||||
"banned": "{user} banned from {command}",
|
||||
"unbanned": "{user} unbanned from {command}",
|
||||
"unban_error": "{user} wasn't banned from that command, fool.",
|
||||
"modehate": "Hating on {user}",
|
||||
"unmodehate": "No longer hating on {user}",
|
||||
"qlock": "Locked quote category: {category}",
|
||||
"spelling_self": "{correcter} meant: {fix}",
|
||||
"spelling_other": "{correcter} thinks {candidate} meant: {fix}"
|
||||
"syntax_error": {
|
||||
"english": "Invalid syntax. Initiate incineration.",
|
||||
"spanish": "Sintaxis no válida. Iniciar incineración."
|
||||
},
|
||||
"spanish": {
|
||||
"syntax_error": "Sintaxis no válida. Iniciar incineración.",
|
||||
"module_load_error": "No se pudó cargar el módulo: {moduleName}",
|
||||
"category_not_found": "Nadie ama a {category}",
|
||||
"large_categories": "Los categorías más grandes: ",
|
||||
"empty_category": "Categoría vacía. Iniciar incineración.",
|
||||
"no_results": "No hubo ningún resultado.",
|
||||
"locked_category": "{category} está cerrada. Comenzar incineración.",
|
||||
"no_quotes": "Ninguna cita existe en {category}",
|
||||
"last_removed": "Última cita quitado de {category}.",
|
||||
"no_recent_adds": "Ninguna cita fue añadido recientamente.",
|
||||
"rmlast_spam": "No me inundes de mierda. Intenta otra vez en unos minutos.",
|
||||
"removed_from": "'{quote}' quitado de {category}",
|
||||
"q_not_exist_under": "'{quote}' no existe en '{category}'.",
|
||||
"total_quotes": "Total de citas: {count}.",
|
||||
"quote_exists": "Cita ya existe. Iniciar incineración.",
|
||||
"quote_saved": "Cita guardada en '{category}' ({count})",
|
||||
"quote_replace": "No sustituites arrays, hijo de puta.",
|
||||
"prune": "Reduciendo categorías vacías {categories}",
|
||||
"no_prune": "Ninguna categoría vacía. Comenzar incineracíon",
|
||||
"command_ban": " está prohibido de usar esta instrucción. Comenzar incineración.",
|
||||
"correction": "¿Querías decir: ",
|
||||
"gpull": "Hecho git pull en esta mierda.",
|
||||
"reload": "Recargado esta mierda.",
|
||||
"load_module": "Cargado módulo nuevo: {moduleName}",
|
||||
"unload_module": "Descargado modulo: {moduleName}",
|
||||
"unload_error": "{moduleName} no está cargado. Idiota.",
|
||||
"banned": "{user} está prohibido de usar {command}",
|
||||
"unbanned": "{user} no está prohibido de user {command}",
|
||||
"unban_error": "{user} no fue prohibido de esta instrucción, tont@..",
|
||||
"modehate": "Odiando a {user}",
|
||||
"unmodehate": "Ni siquera odiando a {user}",
|
||||
"qlock": "Cerrado la categoría: {category}",
|
||||
"spelling_self": "{correcter} quería decir: {fix}",
|
||||
"spelling_other": "{correcter} piensa que {candidate} queria decir: {fix}"
|
||||
"module_load_error": {
|
||||
"english": "Failed to load module: {moduleName}",
|
||||
"spanish": "No se pudó cargar el módulo: {moduleName}"
|
||||
},
|
||||
"category_not_found": {
|
||||
"english": "Nobody loves {category}",
|
||||
"spanish": "Nadie ama a {category}"
|
||||
},
|
||||
"large_categories": {
|
||||
"english": "Largest categories: ",
|
||||
"spanish": "Los categorías más grandes: "
|
||||
},
|
||||
"empty_category": {
|
||||
"english": "That category has no quotes in. Commence incineration.",
|
||||
"spanish": "Categoría vacía. Iniciar incineración."
|
||||
},
|
||||
"no_results": {
|
||||
"english": "No results found.",
|
||||
"spanish": "No hubo ningún resultado."
|
||||
},
|
||||
"locked_category": {
|
||||
"english": "{category} is locked. Commence incineration.",
|
||||
"spanish": "{category} está cerrada. Comenzar incineración."
|
||||
},
|
||||
"no_quotes": {
|
||||
"english": "No quotes exist under {category}",
|
||||
"spanish": "Ninguna cita existe en {category}"
|
||||
},
|
||||
"last_removed": {
|
||||
"english": "Last quote removed from {category}.",
|
||||
"spanish": "Última cita quitado de {category}."
|
||||
},
|
||||
"no_recent_adds": {
|
||||
"english": "No quotes were added recently.",
|
||||
"spanish": "Ninguna cita fue añadido recientamente."
|
||||
},
|
||||
"rmlast_spam": {
|
||||
"english": "No spamming that shit. Try again in a few minutes...",
|
||||
"spanish": "No me inundes de mierda. Intenta otra vez en unos minutos."
|
||||
},
|
||||
"removed_from": {
|
||||
"english": "'{quote}' removed from {category}",
|
||||
"spanish": "'{quote}' quitado de {category}"
|
||||
},
|
||||
"q_not_exist_under": {
|
||||
"english": "'{quote}' doesn't exist under '{category}'.",
|
||||
"spanish": "'{quote}' no existe en '{category}'."
|
||||
},
|
||||
"total_quotes": {
|
||||
"english": "Total quote count: {count}.",
|
||||
"spanish": "Total de citas: {count}."
|
||||
},
|
||||
"quote_exists": {
|
||||
"english": "Quote already in DB. Initiate incineration.",
|
||||
"spanish": "Cita ya existe. Iniciar incineración."
|
||||
},
|
||||
"quote_saved": {
|
||||
"english": "Quote saved in '{category}' ({count}).",
|
||||
"spanish": "Cita guardada en '{category}' ({count})"
|
||||
},
|
||||
"quote_replace": {
|
||||
"english": "No replacing arrays, you whore.",
|
||||
"spanish": "No sustituites arrays, hijo de puta."
|
||||
},
|
||||
"quote_count": {
|
||||
"english": "{category} has {count} quotes."
|
||||
},
|
||||
"prune": {
|
||||
"english": "Pruning empty quote categories: {categories}",
|
||||
"spanish": "Reduciendo categorías vacías {categories}"
|
||||
},
|
||||
"no_prune": {
|
||||
"english": "No empty quote categories. Commence incineration.",
|
||||
"spanish": "Ninguna categoría vacía. Comenzar incineracíon"
|
||||
},
|
||||
"command_ban": {
|
||||
"english": "{user} is banned from using this command. Commence incineration.",
|
||||
"spanish": "{user} está prohibido de usar esta instrucción. Comenzar incineración."
|
||||
},
|
||||
"correction": {
|
||||
"english": "Did you mean: ",
|
||||
"spanish": "¿Querías decir: "
|
||||
},
|
||||
"gpull": {
|
||||
"english": "Git pulled that shit.",
|
||||
"spanish": "Hecho git pull en esta mierda."
|
||||
},
|
||||
"reload": {
|
||||
"english": "Reloaded that shit.",
|
||||
"spanish": "Recargado esta mierda."
|
||||
},
|
||||
"load_module": {
|
||||
"english": "Loaded new module: {moduleName}",
|
||||
"spanish": "Cargado módulo nuevo: {moduleName}"
|
||||
},
|
||||
"unload_module": {
|
||||
"english": "Turned off module: {moduleName}",
|
||||
"spanish": "Descargado modulo: {moduleName}"
|
||||
},
|
||||
"unload_error": {
|
||||
"english": "{moduleName} isn't loaded. Idiot.",
|
||||
"spanish": "{moduleName} no está cargado. Idiota."
|
||||
},
|
||||
"banned": {
|
||||
"english": "{user} banned from {command}",
|
||||
"spanish": "{user} está prohibido de usar {command}"
|
||||
},
|
||||
"unbanned": {
|
||||
"english": "{user} unbanned from {command}",
|
||||
"spanish": "{user} no está prohibido de user {command}"
|
||||
},
|
||||
"unban_error": {
|
||||
"english": "{user} wasn't banned from that command, fool.",
|
||||
"spanish": "{user} no fue prohibido de esta instrucción, tont.."
|
||||
},
|
||||
"modehate": {
|
||||
"english": "Hating on {user}",
|
||||
"spanish": "Odiando a {user}"
|
||||
},
|
||||
"unmodehate": {
|
||||
"english": "No longer hating on {user}",
|
||||
"spanish": "Ni siquera odiando a {user}"
|
||||
},
|
||||
"qlock": {
|
||||
"english": "Locked quote category: {category}",
|
||||
"spanish": "Cerrado la categoría: {category}"
|
||||
},
|
||||
"spelling_self": {
|
||||
"english": "{correcter} meant: {fix}",
|
||||
"spanish": "{correcter} quería decir: {fix}"
|
||||
},
|
||||
"spelling_other": {
|
||||
"english": "{correcter} thinks {candidate} meant: {fix}",
|
||||
"spanish": "{correcter} piensa que {candidate} queria decir: {fix}"
|
||||
},
|
||||
"quote_link": {
|
||||
"english": "Link to {category}"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user