diff --git a/src/components/MenuAppBar/MenuAppBar.js b/src/components/MenuAppBar/MenuAppBar.js
index 77c27b5..dfa660b 100644
--- a/src/components/MenuAppBar/MenuAppBar.js
+++ b/src/components/MenuAppBar/MenuAppBar.js
@@ -7,8 +7,12 @@ import M from "materialize-css";
import { Link } from "react-router-dom";
import { AuthService, NotificationService } from "services";
+import { getLang, setLang } from "i18n/i18n";
class MenuAppBar extends Component {
+ state = {
+ lang: getLang()
+ }
componentDidMount() {
const dropdown = document.querySelectorAll(".dropdown-trigger");
@@ -22,6 +26,14 @@ class MenuAppBar extends Component {
NotificationService.notifySuccess("Logout realizado com sucesso");
};
+ handleLangChange = lang => {
+ setLang(lang)
+ this.setState({
+ lang
+ });
+ window.location.reload();
+ }
+
render() {
const { userConfig } = this.props;
@@ -47,6 +59,22 @@ class MenuAppBar extends Component {
+
+ -
+
+ {this.state.lang}
+ arrow_drop_down
+
+
+ -
+ this.handleLangChange('en')} to="#">EN
+
+ -
+ this.handleLangChange('pt_BR')} to="#">PT-BR
+
+
+
+
;
diff --git a/src/i18n/en.js b/src/i18n/en.js
new file mode 100644
index 0000000..29b1ecf
--- /dev/null
+++ b/src/i18n/en.js
@@ -0,0 +1,2 @@
+export default {
+}
\ No newline at end of file
diff --git a/src/i18n/i18n.js b/src/i18n/i18n.js
new file mode 100644
index 0000000..ab584b7
--- /dev/null
+++ b/src/i18n/i18n.js
@@ -0,0 +1,43 @@
+import ptBr from './pt_BR'
+import en from './en'
+
+import LocalStoreService from "services/LocalStoreService";
+
+const langs = {
+ 'pt_BR':ptBr,
+ 'en': en
+}
+
+function _accessByString(o, s) {
+ s = s.replace(/\[(\w+)\]/g, '.$1');
+ s = s.replace(/^\./, '');
+ var a = s.split('.');
+ for (var i = 0, n = a.length; i < n; ++i) {
+ var k = a[i];
+ if (k in o) {
+ o = o[k];
+ } else {
+ return;
+ }
+ }
+ return o;
+}
+
+function t(key) {
+ const lang = langs[getLang()]
+ const result = _accessByString(lang, key)
+ if (result) {
+ return result
+ }
+ return `{${key}}`;
+}
+
+export function getLang() {
+ return LocalStoreService.getI18n() || 'en'
+}
+
+export function setLang(lang) {
+ LocalStoreService.setI18n(lang)
+}
+
+export default t
\ No newline at end of file
diff --git a/src/i18n/pt_BR.js b/src/i18n/pt_BR.js
new file mode 100644
index 0000000..c93f573
--- /dev/null
+++ b/src/i18n/pt_BR.js
@@ -0,0 +1,45 @@
+export default {
+ unauthorized: "",
+ login: {
+ title: "Login",
+ submit: "Entrar",
+ usernameLabel: "Usuário",
+ passwordLabel: "Senha",
+ successMessage: "Login realizado com sucesso",
+ failureMessage: "Usuário e/ou senha inválido(s)"
+ },
+ boards: {
+ allOwners: "Todos",
+ new: "Novo Board",
+ filter: {
+ title: 'Filtro',
+ button: 'Filtrar'
+ },
+ nameLabel: "Nome",
+ ownerLabel: "Dono",
+ empytBoardList: 'Nenhum board encontrado',
+ remove: {
+ success: "Board removido com sucesso",
+ failure: "Falha ao remover o board"
+ },
+ clone: {
+ success: 'Board duplicado com sucesso',
+ failure: 'Falha ao duplicar o board'
+ },
+ dropdown: {
+ actions: {
+ edit: "Configurações",
+ dynamicFieldConfigs: "Campos Dinâmicos",
+ leadTimeConfigs: "Configurações de Lead Times",
+ holidays: "Feriados",
+ clone: "Duplicar",
+ remove: "Remover"
+ }
+ },
+ buttons: {
+ estimates: "Previsibilidade",
+ issues: "SandBox",
+ issuePeriods: "Períodos"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/pages/Board/ListBoard/CardBoard/CardBoard.js b/src/pages/Board/ListBoard/CardBoard/CardBoard.js
index ee07804..cd4737d 100644
--- a/src/pages/Board/ListBoard/CardBoard/CardBoard.js
+++ b/src/pages/Board/ListBoard/CardBoard/CardBoard.js
@@ -8,6 +8,8 @@ import { AlertService, HttpService, NotificationService } from "services";
import { Button, Col } from "components/ui";
import { Link } from "react-router-dom";
+import t from 'i18n/i18n'
+
import M from "materialize-css";
import "./CardBoard.scss";
@@ -36,15 +38,15 @@ class CardBoard extends Component {
const willDelete = await AlertService.confirmRemove();
if (willDelete) {
await HttpService.delete(`/boards/${board.id}`);
- NotificationService.notifySuccess("Board removido com sucesso");
+ NotificationService.notifySuccess(t('boards.remove.success'));
this.props.refreshBoards();
}
} catch (e) {
- NotificationService.notifyError("Falha ao remover o board");
+ NotificationService.notifyError(t('boards.remove.failure'));
}
};
- copyBoard = async () => {
+ cloneBoard = async () => {
const { board } = this.props;
try {
@@ -54,10 +56,10 @@ class CardBoard extends Component {
}
});
- NotificationService.notifySuccess("Board duplicado com sucesso");
+ NotificationService.notifySuccess(t('boards.clone.success'));
this.props.refreshBoards();
} catch (e) {
- NotificationService.notifyError("Falha ao duplicar o board");
+ NotificationService.notifyError(t('boards.clone.failure'));
}
};
@@ -73,33 +75,47 @@ class CardBoard extends Component {
-
- Configurações
+
+ {t('boards.dropdown.actions.edit')}
+
-
- Campos Dinâmicos
+
+ {t('boards.dropdown.actions.dynamicFieldConfigs')}
+
-
- Configurações de Lead Times
+
+ {t('boards.dropdown.actions.leadTimeConfigs')}
+
-
- Feriados
+
+ {t('boards.dropdown.actions.holidays')}
+
-
-
{userConfig.username === board.owner && -
- Remover
+ {t('boards.dropdown.actions.remove')}
}
- Previsibilidade
- SandBox
- Períodos
+
+ {t('boards.buttons.estimates')}
+
+
+ {t('boards.buttons.issues')}
+
+
+ {t('boards.buttons.issuePeriods')}
+
;
diff --git a/src/pages/Board/ListBoard/EmptyBoardAlert/EmptyBoardAlert.js b/src/pages/Board/ListBoard/EmptyBoardAlert/EmptyBoardAlert.js
index 969b119..63507ee 100644
--- a/src/pages/Board/ListBoard/EmptyBoardAlert/EmptyBoardAlert.js
+++ b/src/pages/Board/ListBoard/EmptyBoardAlert/EmptyBoardAlert.js
@@ -4,7 +4,9 @@ import { Col } from "components/ui";
import "./EmptyBoardAlert.scss";
+import t from 'i18n/i18n';
+
export default () =>
- Nenhum board encontrado
+ {t('boards.empytBoardList')}
;
diff --git a/src/pages/Board/ListBoard/ListBoard.js b/src/pages/Board/ListBoard/ListBoard.js
index ad71d74..5bce73e 100644
--- a/src/pages/Board/ListBoard/ListBoard.js
+++ b/src/pages/Board/ListBoard/ListBoard.js
@@ -9,6 +9,8 @@ import { Button, Col, InputField, Link, Pagination, Panel, Preloader, Row, Selec
import CardBoard from "./CardBoard/CardBoard";
import EmptyBoardAlert from "./EmptyBoardAlert/EmptyBoardAlert";
+import t from "i18n/i18n";
+
class ListBoard extends Component {
state = {
boards: {
@@ -59,7 +61,7 @@ class ListBoard extends Component {
const { data } = await HttpService.get("/boards/owners");
const owners = [
{
- label: "Todos",
+ label: t('boards.allOwners'),
value: "all"
},
...data.map(owner => ({
@@ -127,14 +129,14 @@ class ListBoard extends Component {
return
Novo board
+ {t('boards.new')}
}/>
-
- Filtrar
+ {t('boards.filter.button')}
}>
@@ -142,12 +144,12 @@ class ListBoard extends Component {
name="name"
onChange={e => this.changeFilterValue("name", e.target.value)}
value={filter.name}
- label="Nome"/>
+ label={t('boards.nameLabel')}/>