Skip to content

Commit

Permalink
More translations
Browse files Browse the repository at this point in the history
  • Loading branch information
robsonbittencourt committed Mar 8, 2017
1 parent af6af43 commit abf0ca5
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 36 deletions.
20 changes: 17 additions & 3 deletions locales/en-US/translation.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
{
"firstUse": {
"message1": "My name is {{botName}} and from now on I will help you with some tasks using the Slack."
},
"locale": {
"change": "hubot change the language to $",
"sucess": "Language changed to *{{language}}*",
"error": "Ops. I don't know the language *{{language}}*"
},
"hello": "Hello,",
"thanks": "Thanks,",
"ops": "Ops! ",
"firstUse": {
"message1": "My name is {{botName}} and from now on I will help you with some tasks using the Slack.",
"message2": "Before I need you to do some settings. How was you who started me I will define you as my system administrator. So you can access the settings in the future.",
"message3": "Initially I do not know perform tasks. But there are gears that when coupled to me add me skills.",
"message4": "At this time all the gears are active. You can deactivate them using the command ",
"message5": "Some gears have settings. To let them use the command ",
"message6": "Below is a list of gears available:"
},
"gears": {
"deactivate": "deactivate gear-name",
"configure": "configure gear-name"
}
}


18 changes: 15 additions & 3 deletions locales/pt-BR/translation.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
{
"firstUse": {
"message1": "My name is {{botName}} and from now on I will help you with some tasks using the Slack."
},
"locale": {
"change": "hubot alterar idioma para $",
"sucess": "Idioma alterado para *{{language}}*",
"error": "Ops. Eu não conheço o idioma *{{language}}*"
},
"hello": "Olá,",
"thanks": "Obrigado,",
"ops": "Ops! ",
"firstUse": {
"message1": "Meu nome é {{botName}} e apartir de agora eu vou lhe ajudar com algumas tarefas utilzando o Slack.",
"message2": "Antes eu preciso que você faça algumas configurações. Como foi você que me iniciou vou definí-lo como meu administrador. Então você pode acessar as configurações no futuro.",
"message3": "Inicialmente eu não sei fazer muitas coisas. Mas existem engrenagens que quando acopladas à mim me adicionam habilidades.",
"message4": "Neste momento todas as engrenagens estão ativas. Você pode desativá-las utilizando o comando ",
"message5": "Algumas engrenagens possuem configurações. Para fazê-las use o comando ",
"message6": "Abaixo segue uma lista com as engrenagens disponíveis:"
},
"gears": {
"deactivate": "desativar gear-name",
"configure": "configurar gear-name"
}
}
27 changes: 5 additions & 22 deletions src/first-run.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,24 @@ function firstRun(core, message) {
const messageDelay = 3000;

hubot.speak(message, message1(hubot, core, message), null, messageDelay)
.then(() => hubot.speak(message, message2(hubot), null, messageDelay))
.then(() => hubot.speak(message, message3(hubot), null, messageDelay))
.then(() => hubot.speak(message, 'firstUse.message2', null, messageDelay))
.then(() => hubot.speak(message, 'firstUse.message3', null, messageDelay))
.then(() => hubot.speak(message, message4(hubot), null, messageDelay))
.then(() => hubot.speak(message, message5(hubot), null, messageDelay))
.then(() => hubot.speak(message, message6(hubot), null, messageDelay))
.then(() => hubot.speak(message, 'firstUse.message6', null, messageDelay))
.then(() => hubot.speak(message, postGearsNames(hubot), null, messageDelay));
}

function message1(hubot, core, message) {
return hubot.speech().hello(core.getUserById(message.user)).append('firstUse.message1', { botName: 'hubot' }).end();
}

function message2(hubot) {
return hubot.speech().append('Before I need you to do some settings.')
.append(' How was you who started me I will define you as my system administrator.')
.append(' So you can access the settings in the future.').end();
}

function message3(hubot) {
return hubot.speech().append('Initially I do not know perform tasks.')
.append(' But there are gears that when coupled to me add me skills.').end();
}

function message4(hubot) {
return hubot.speech().append('At this time all the gears are active. You can deactivate them using the command ')
.bold('deactivate gear-name').period().end();
return hubot.speech().append('firstUse.message4').bold('gears.deactivate').period().end();
}

function message5(hubot) {
return hubot.speech().append('Some gears have settings. To let them use the command ')
.bold('configure gear-name').period().end();
}

function message6(hubot) {
return hubot.speech().append('Below is a list of gears available:').end();
return hubot.speech().append('firstUse.message5').bold('gears.configure').period().end();
}

function postGearsNames(hubot) {
Expand Down
6 changes: 5 additions & 1 deletion src/lib/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ i18n.use(backend)
.init(initOptions);

function t(key, vars) {
return i18n.exists(key) ? i18n.t(key, vars) : key;
if (i18n.exists(key)) {
return vars ? i18n.t(key, vars) : i18n.t(key);
}

return key;
}

function changeLanguage(locale) {
Expand Down
14 changes: 7 additions & 7 deletions src/speech.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ Speecher.prototype.append = function append(text, vars) {
};

Speecher.prototype.hello = function hello(user) {
this.append('Hello,').user(user).append('! ');
this.append('hello').user(user).append('! ');
return this;
};

Speecher.prototype.thanks = function thanks(user) {
this.append('Thanks,').user(user).append('!! ');
this.append('thanks').user(user).append('!! ');
return this;
};

Expand All @@ -52,20 +52,20 @@ Speecher.prototype.channel = function channel() {
};

Speecher.prototype.bold = function bold(text, vars) {
const trasnlatedText = i18n.t(text, vars);
this.append(`*${trasnlatedText}*`);
const translatedText = i18n.t(text, vars);
this.append(`*${translatedText}*`);
return this;
};

Speecher.prototype.italic = function italic(text, vars) {
const trasnlatedText = i18n.t(text, vars);
this.append(`_${trasnlatedText}_`);
const translatedText = i18n.t(text, vars);
this.append(`_${translatedText}_`);
return this;
};

Speecher.prototype.errorOccurs = function errorOccurs(text) {
this.isError = true;
this.init().append(':exclamation: _').append(`Ops! ${optionalText(text)}`);
this.init().append(':exclamation: _').append('ops').append(optionalText(text));
return this;
};

Expand Down

0 comments on commit abf0ca5

Please sign in to comment.