Skip to content

Commit

Permalink
fixed locale pt-br not being used and added extra suport for pt-br (#…
Browse files Browse the repository at this point in the history
…1745)

* fixed locale pt-br not being used and added extra suport for pt-br

* translating missing values pt-br

* update CHANGELOG and LOCALIZATION
  • Loading branch information
pedropacheco92 authored and Corina committed Feb 20, 2019
1 parent c3b2a6d commit db34ce4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 10 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `core`: Reworked logic on connect/disconnect for reliability on handling corner cases, by [@compulim](https://github.com/compulim) in PR [#1649](https://github.com/Microsoft/BotFramework-WebChat/pull/1649)
- `core`: Fix [#1521](https://github.com/Microsoft/BotFramework-WebChat/issues/1521). Add connectivity status component and update localization, by [@corinagum](https://github.com/corinagum) in PR [#1679](https://github.com/Microsoft/BotFramework-WebChat/pull/1679)
- `core`: Fix [#1057](https://github.com/Microsoft/BotFramework-WebChat/issues/1057). Fixed suggested actions destined for other recipients should not show up, by [@compulim](https://github.com/compulim) in PR [#1706](https://github.com/Microsoft/BotFramework-WebChat/pull/1706)
- `component`: Fixed pt-br locale not being selected, added `X minutes ago` and missing translations, by [@pedropacheco92](https://github.com/pedropacheco92) in PR [#1745](https://github.com/Microsoft/BotFramework-WebChat/pull/1745)
- `component`: Fix [#1741](https://github.com/Microsoft/BotFramework-WebChat/issues/1741) where `scrollToEndButton` does not have `type="button"`by [@corinagum](https://github.com/corinagum) in PR [#1743](https://github.com/Microsoft/BotFramework-WebChat/pull/1743)

### Removed
Expand Down
2 changes: 1 addition & 1 deletion LOCALIZATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ If you want to help to translate Web Chat to different language, please submit a
| nb-no | @taarskog |
| nl-nl | @iMicknl |
| pl-pl | @peterblazejewicz |
| pt-br | @rcarubbi |
| pt-br | @rcarubbi, @pedropacheco92 |
| pt-pt | |
| ru-ru | @odysseus1973 |
| sv-se | |
Expand Down
2 changes: 1 addition & 1 deletion packages/component/src/Localization/Localize.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function normalizeLanguage(language) {
} else if (language.startsWith('pl')) {
return 'pl-PL';
} else if (language.startsWith('pt')) {
if (language === 'pt-BR') {
if (language === 'pt-br') {
return 'pt-BR';
} else {
return 'pt-PT';
Expand Down
57 changes: 49 additions & 8 deletions packages/component/src/Localization/pt-BR.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,64 @@
function xMinutesAgo(dateStr) {
const date = new Date(dateStr);
const dateTime = date.getTime();

if (isNaN(dateTime)) {
return dateStr;
}

const now = Date.now();
const deltaInMs = now - dateTime;
const deltaInMinutes = Math.floor(deltaInMs / 60000);
const deltaInHours = Math.floor(deltaInMs / 3600000);

if (deltaInMinutes < 1) {
return 'Agora a pouco';
} else if (deltaInMinutes === 1) {
return 'Um minuto atrás';
} else if (deltaInHours < 1) {
return `${ deltaInMinutes } minutos atrás`;
} else if (deltaInHours === 1) {
return `Uma hora atrás`;
} else if (deltaInHours < 5) {
return `${ deltaInHours } horas atrás`;
} else if (deltaInHours <= 24) {
return `Hoje`;
} else if (deltaInHours <= 48) {
return `Ontem`;
} else if (window.Intl) {
return new Intl.DateTimeFormat('pt-BR').format(date);
} else {
return date.toLocaleString('pt-BR', {
day: '2-digit',
hour: '2-digit',
hour12: false,
minute: '2-digit',
month: '2-digit',
year: 'numeric',
});
}
}

export default {
// FAILED_CONNECTION_NOTIFICATION: '',
FAILED_CONNECTION_NOTIFICATION: 'Não foi possível conectar',
// Do not localize {Retry}; it is a placeholder for "Retry". English translation should be, "Send failed. Retry."
SEND_FAILED_KEY: 'não pude enviar, {Retry}.',
// SLOW_CONNECTION_NOTIFICATION: '',
SLOW_CONNECTION_NOTIFICATION: 'A conexão está levando mais tempo que o normal.',
'Chat': 'Bate-papo',
// 'Download file': '',
// 'Microphone off': '',
// 'Microphone on': '',
'Download file': 'Baixar arquivo',
'Microphone off': 'Microfone desligado',
'Microphone on': 'Microfone ligado',
'Listening…': 'Ouvindo…',
'retry': 'repetir',
'Retry': '{retry}', // Please alter this value if 'Retry' at the beginning of a sentence is written differently than at the end of a sentence.
'Send': 'Enviar',
'Sending': 'enviando',
'Speak': 'Falar',
// 'Starting…': '',
'Starting…': 'Iniciando…',
'Tax': 'Imposto',
'Total': 'Total',
'Type your message': 'Digite sua mensagem',
'Upload file': 'Subir arquivo',
'VAT': 'VAT'
// 'X minutes ago':
'VAT': 'VAT',
'X minutes ago': xMinutesAgo
}

0 comments on commit db34ce4

Please sign in to comment.