Skip to content
This repository was archived by the owner on Jan 16, 2022. It is now read-only.

Commit 4467be9

Browse files
feat(i18n): added i18next
1 parent 8d4b3ce commit 4467be9

File tree

74 files changed

+1056
-714
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1056
-714
lines changed

i18n/config.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import i18n from 'i18next';
2+
import { initReactI18next } from 'react-i18next';
3+
4+
import translationEN from './translations/en-US.json';
5+
import translationPT from './translations/pt-BR.json';
6+
7+
i18n
8+
// pass the i18n instance to react-i18next.
9+
.use(initReactI18next)
10+
// init i18next
11+
// for all options read: https://www.i18next.com/overview/configuration-options
12+
.init({
13+
// in case window.VEDACCIO_LANGUAGE is undefined,it will fall back to 'en-US'
14+
lng: window.VEDACCIO_LANGUAGE,
15+
fallbackLng: 'en-US',
16+
whitelist: ['en-US', 'pt-BR'],
17+
load: 'currentOnly',
18+
resources: {
19+
'en-US': {
20+
translation: translationEN,
21+
},
22+
'pt-BR': {
23+
translation: translationPT,
24+
},
25+
},
26+
debug: false,
27+
interpolation: {
28+
escapeValue: false, // react already safes from xss
29+
},
30+
});
31+
export default i18n;

i18n/translations/en-US.json

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"action-bar-action": {
3+
"visit-home-page": "Visit homepage",
4+
"open-an-issue": "Open an issue",
5+
"download-tarball": "Download tarball"
6+
},
7+
"dialog": {
8+
"registry-info": {
9+
"title": "Register Info"
10+
}
11+
},
12+
"header": {
13+
"documentation": "Documentation",
14+
"registry-info": "Registry Information",
15+
"greetings": "Hi "
16+
},
17+
"search": {
18+
"packages": "Search Packages"
19+
},
20+
"auto-complete": {
21+
"loading": "Loading...",
22+
"no-results-found": "No results found."
23+
},
24+
"tab": {
25+
"uplinks": "Uplinks",
26+
"versions": "Versions",
27+
"dependencies": "Dependencies",
28+
"readme": "Readme"
29+
},
30+
"uplinks": {
31+
"title": "Uplinks",
32+
"no-items": "{{name}} has no uplinks."
33+
},
34+
"versions": {
35+
"current-tags": "Current Tags",
36+
"version-history": "Version history",
37+
"not-available": "Not available"
38+
},
39+
"package": {
40+
"published-on": "Published on {{time}} •",
41+
"version": "v{{version}}",
42+
"visit-home-page": "Visit homepage",
43+
"homepage": "Homepage",
44+
"open-an-issue": "Open an issue",
45+
"bugs": "Bugs",
46+
"download": "Download {{what}}",
47+
"the-tar-file": "the tar file",
48+
"tarball": "Tarball"
49+
},
50+
"dependencies": {
51+
"has-no-dependencies": "{{package}} has no dependencies.",
52+
"dependency-block": "{{package}}@{{version}}"
53+
},
54+
"form": {
55+
"username": "Username",
56+
"password": "Password"
57+
},
58+
"form-placeholder": {
59+
"username": "Your username",
60+
"password": "Your strong password"
61+
},
62+
"form-validation": {
63+
"required-field": "This field is required",
64+
"required-min-length": "This field required the min length of {{length}}",
65+
"unable-to-sign-in": "Unable to sign in",
66+
"username-or-password-cant-be-empty": "Username or password can't be empty!"
67+
},
68+
"help": {
69+
"title": "No Package Published Yet.",
70+
"sub-title": "To publish your first package just:",
71+
"first-step": "1. Login",
72+
"first-step-command-line": "npm adduser --registry {{registryUrl}}",
73+
"second-step": "2. Publish",
74+
"second-step-command-line": "npm publish --registry {{registryUrl}}",
75+
"third-step": "3. Refresh this page."
76+
},
77+
"sidebar": {
78+
"detail": {
79+
"latest-version": "Latest v{{version}}",
80+
"version": "v{{version}}"
81+
},
82+
"installation": {
83+
"title": "Installation",
84+
"install-using-yarn": "Install using yarn",
85+
"install-using-yarn-command": "yarn add {{packageName}}",
86+
"install-using-npm": "Install using npm",
87+
"install-using-npm-command": "npm install {{packageName}}",
88+
"install-using-pnpm": "Install using pnpm",
89+
"install-using-pnpm-command": "pnpm install {{packageName}}"
90+
},
91+
"repository": {
92+
"title": "Repository"
93+
},
94+
"author": {
95+
"title": "Author"
96+
},
97+
"distribution": {
98+
"title": "Latest Distribution",
99+
"license": "License",
100+
"size": "Size",
101+
"file-count": "file count"
102+
},
103+
"maintainers": {
104+
"title": "Maintainers"
105+
},
106+
"contributors": {
107+
"title": "Contributors"
108+
},
109+
"engines": {
110+
"npm-version": "NPM Version",
111+
"node-js": "NODE JS"
112+
}
113+
},
114+
"footer": {
115+
"powered-by": "Powered by",
116+
"made-with-love-on": "Made with <0>♥</0> on"
117+
},
118+
"button": {
119+
"close": "Close",
120+
"cancel": "Cancel",
121+
"login": "Login",
122+
"logout": "Logout",
123+
"go-to-the-home-page": "Go to the home page",
124+
"learn-more": "Learn More",
125+
"fund-this-package": "<0>Fund</0> this package"
126+
},
127+
"error": {
128+
"unspecific": "Something went wrong.",
129+
"404": {
130+
"page-not-found": "404 - Page not found",
131+
"sorry-we-could-not-find-it": "Sorry, we couldn't find it..."
132+
},
133+
"app-context-not-correct-used": "The app context was not correct used",
134+
"package-meta-is-required-at-detail-context": "packageMeta is required at DetailContext"
135+
}
136+
}

i18n/translations/pt-BR.json

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"action-bar-action": {
3+
"visit-home-page": "Visitar a página inicial",
4+
"open-an-issue": "Abrir um incidente",
5+
"download-tarball": "Baixar Tarball"
6+
},
7+
"dialog": {
8+
"registry-info": {
9+
"title": "Informações do Registro"
10+
}
11+
},
12+
"header": {
13+
"documentation": "Documentação",
14+
"registry-info": "Informações do Registro",
15+
"greetings": "Oi "
16+
},
17+
"search": {
18+
"packages": "Pesquisar Pacotes"
19+
},
20+
"auto-complete": {
21+
"loading": "Carregando...",
22+
"no-results-found": "Nenhum resultado encontrado."
23+
},
24+
"tab": {
25+
"uplinks": "Uplinks",
26+
"versions": "Versões",
27+
"dependencies": "Dependências",
28+
"readme": "Leia-me"
29+
},
30+
"uplinks": {
31+
"title": "Uplinks",
32+
"no-items": "{{name}} não tem uplinks."
33+
},
34+
"versions": {
35+
"current-tags": "Tags atuais",
36+
"version-history": "Version history",
37+
"not-available": "Not available"
38+
},
39+
"package": {
40+
"published-on": "Publicado em {{time}} •",
41+
"version": "v{{version}}",
42+
"visit-home-page": "Visitar a página inicial",
43+
"homepage": "Página inicial",
44+
"open-an-issue": "Criar um incidente",
45+
"bugs": "Erros",
46+
"download": "Baixar {{what}}",
47+
"the-tar-file": "o arquivo tar",
48+
"tarball": "Tarball"
49+
},
50+
"dependencies": {
51+
"has-no-dependencies": "{{package}} não tem dependências.",
52+
"dependency-block": "{{package}}@{{version}}"
53+
},
54+
"form": {
55+
"username": "Nome do usuário",
56+
"password": "Senha"
57+
},
58+
"form-placeholder": {
59+
"username": "O seu nome",
60+
"password": "A sua senha forte"
61+
},
62+
"form-validation": {
63+
"required-field": "Este campo é obrigatório",
64+
"required-min-length": "Este campo requer o mínimo de {{length}} caracteres",
65+
"unable-to-sign-in": "Não foi possível fazer login",
66+
"username-or-password-cant-be-empty": "Nome de usuário ou senha não podem estar vazios!"
67+
},
68+
"help": {
69+
"title": "Nenhum pacote publicado ainda.",
70+
"sub-title": "Para publicar seu primeiro pacote apenas:",
71+
"first-step": "1. Faça login",
72+
"first-step-command-line": "npm adduser --registry {{registryUrl}}",
73+
"second-step": "2. Publique",
74+
"second-step-command-line": "npm publish --registry {{registryUrl}}",
75+
"third-step": "3. Atualize esta página."
76+
},
77+
"sidebar": {
78+
"detail": {
79+
"latest-version": "Última v{{version}}",
80+
"version": "v{{version}}"
81+
},
82+
"installation": {
83+
"title": "Instalação",
84+
"install-using-yarn": "Instale usando yarn",
85+
"install-using-yarn-command": "yarn add {{packageName}}",
86+
"install-using-npm": "Instale usando npm",
87+
"install-using-npm-command": "npm install {{packageName}}",
88+
"install-using-pnpm": "Instale usando pnpm",
89+
"install-using-pnpm-command": "pnpm install {{packageName}}"
90+
},
91+
"repository": {
92+
"title": "Repositório"
93+
},
94+
"author": {
95+
"title": "Autor(a)"
96+
},
97+
"distribution": {
98+
"title": "Distribuição mais recente",
99+
"license": "Licença",
100+
"size": "Tamanho",
101+
"file-count": "Contagem de arquivos"
102+
},
103+
"maintainers": {
104+
"title": "Mantenedores(as)"
105+
},
106+
"contributors": {
107+
"title": "Contribuidores(as)"
108+
},
109+
"engines": {
110+
"npm-version": "Versão NPM",
111+
"node-js": "NODE JS"
112+
}
113+
},
114+
"footer": {
115+
"powered-by": "Distribuído por",
116+
"made-with-love-on": "Feito com amor <0>♥</0> no(a)"
117+
},
118+
"button": {
119+
"close": "Fechar",
120+
"cancel": "Cancelar",
121+
"login": "Conectar",
122+
"logout": "Desconectar",
123+
"go-to-the-home-page": "Ir para a página inicial",
124+
"learn-more": "Leia mais",
125+
"fund-this-package": "<0>Financie</0> este pacote"
126+
},
127+
"error": {
128+
"unspecific": "Algo deu errado.",
129+
"404": {
130+
"page-not-found": "404 - Página não encontrada",
131+
"sorry-we-could-not-find-it": "Desculpe, não conseguimos encontrar..."
132+
},
133+
"app-context-not-correct-used": "O contexto do aplicativo não foi usado corretamente",
134+
"package-meta-is-required-at-detail-context": "packageMeta é requerido em DetailContext"
135+
}
136+
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"github-markdown-css": "3.0.1",
7272
"html-webpack-plugin": "3.2.0",
7373
"husky": "3.1.0",
74+
"i18next": "19.1.0",
7475
"identity-obj-proxy": "3.0.0",
7576
"in-publish": "2.0.0",
7677
"jest": "24.9.0",
@@ -99,6 +100,7 @@
99100
"react-dom": "16.13.0",
100101
"react-hook-form": "3.29.4",
101102
"react-hot-loader": "4.12.18",
103+
"react-i18next": "11.3.1",
102104
"react-router-dom": "5.1.2",
103105
"request": "2.88.0",
104106
"resolve-url-loader": "3.1.1",

src/App/App.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import React, { useState, useEffect } from 'react';
1+
/* eslint-disable react/jsx-max-depth */
2+
import React, { useState, useEffect, Suspense } from 'react';
23
import styled from '@emotion/styled';
34
import isNil from 'lodash/isNil';
45
import { Router } from 'react-router-dom';
@@ -7,9 +8,11 @@ import storage from '../utils/storage';
78
import { isTokenExpire } from '../utils/login';
89
import Header from '../components/Header';
910
import Footer from '../components/Footer';
11+
import Loading from '../components/Loading';
1012
import Box from '../muiComponents/Box';
1113
import StyleBaseline from '../design-tokens/StyleBaseline';
1214
import { Theme } from '../design-tokens/theme';
15+
import '../../i18n/config';
1316

1417
import AppContextProvider from './AppContextProvider';
1518
import AppRoute, { history } from './AppRoute';
@@ -31,7 +34,6 @@ const StyledBoxContent = styled(Box)<{ theme?: Theme }>(({ theme }) => ({
3134
/* eslint-disable react-hooks/exhaustive-deps */
3235
const App: React.FC = () => {
3336
const [user, setUser] = useState();
34-
3537
/**
3638
* Logout user
3739
* Required by: <Header />
@@ -60,23 +62,22 @@ const App: React.FC = () => {
6062
}, []);
6163

6264
return (
63-
<>
65+
<Suspense fallback={<Loading />}>
6466
<StyleBaseline />
6567
<StyledBox display="flex" flexDirection="column" height="100%">
6668
<>
6769
<Router history={history}>
6870
<AppContextProvider user={user}>
6971
<Header />
7072
<StyledBoxContent flexGrow={1}>
71-
{/* eslint-disable-next-line react/jsx-max-depth */}
7273
<AppRoute />
7374
</StyledBoxContent>
7475
</AppContextProvider>
7576
</Router>
7677
<Footer />
7778
</>
7879
</StyledBox>
79-
</>
80+
</Suspense>
8081
);
8182
};
8283

0 commit comments

Comments
 (0)