forked from GitHub/dbot
Merge pull request #313 from JohnMaguire2013/master
refactored DBot.prototype.t to add new error case
This commit is contained in:
commit
ccef54fd2f
@ -199,7 +199,7 @@ var commands = function(dbot) {
|
|||||||
'url': dbot.t('url', {
|
'url': dbot.t('url', {
|
||||||
'host': dbot.config.web.webHost,
|
'host': dbot.config.web.webHost,
|
||||||
'port': dbot.config.web.webPort,
|
'port': dbot.config.web.webPort,
|
||||||
'path': 'quotes/' + key
|
'path': 'quotes/' + encodeURIComponent(key)
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
|
7
run.js
7
run.js
@ -86,16 +86,17 @@ DBot.prototype.say = function(server, channel, message) {
|
|||||||
|
|
||||||
// Format given stored string in config language
|
// Format given stored string in config language
|
||||||
DBot.prototype.t = function(string, formatData) {
|
DBot.prototype.t = function(string, formatData) {
|
||||||
var formattedString;
|
var formattedString = 'String not found. Something has gone screwy. Maybe.';
|
||||||
|
|
||||||
if(_.has(this.strings, string)) {
|
if(_.has(this.strings, string)) {
|
||||||
var lang = this.config.language;
|
var lang = this.config.language;
|
||||||
if(!_.has(this.strings[string], lang)) {
|
if(!_.has(this.strings[string], lang)) {
|
||||||
lang = "en";
|
lang = "en";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(_.has(this.strings[string], lang)) {
|
||||||
formattedString = this.strings[string][lang].format(formatData);
|
formattedString = this.strings[string][lang].format(formatData);
|
||||||
} else {
|
}
|
||||||
formattedString = 'String not found. Something has gone screwy. Maybe.';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return formattedString;
|
return formattedString;
|
||||||
|
Loading…
Reference in New Issue
Block a user