-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from vnscosta/feat/i18n
feat: config i18n and language control
- Loading branch information
Showing
16 changed files
with
1,859 additions
and
1,588 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"semi": true, | ||
"tabWidth": 2, | ||
"printWidth": 100, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"jsxSingleQuote": true, | ||
"bracketSpacing": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"toolbar": { | ||
"menu": { | ||
"about": "What is planning poker?", | ||
"guide": "Guide", | ||
"examples": "Examples", | ||
"newSession": "New session", | ||
"joinSession": "Join session" | ||
} | ||
}, | ||
"HomePage": { | ||
"heroSection": { | ||
"title": "Free Planning Poker App", | ||
"description": "Free / Open source Planning Poker Web App to estimate user stories for your Agile/Scrum teams. Create a session and invite your team members to estimate user stories efficiently.", | ||
"formNewSession": { | ||
"newSessionHeader": "Create new session", | ||
"sessionNameLabel": "Session name", | ||
"yourNameLabel": "Your name" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"toolbar": { | ||
"menu": { | ||
"about": "Sobre o planning poker", | ||
"guide": "Guia", | ||
"examples": "Exemplos", | ||
"newSession": "Nova sessão", | ||
"joinSession": "Entrar na sessão" | ||
} | ||
}, | ||
"HomePage": { | ||
"heroSection": { | ||
"title": "Sistema grátis de Planning Poker", | ||
"description": "Sistema de Planning Poker grátis e open source para estimativa de histórias dos usuários para seu time ágil/scrum. Crie uma sessão e convide membros do seu time para estimar as histórias com eficiência.", | ||
"formNewSession": { | ||
"newSessionHeader": "Criar nova sessão", | ||
"sessionNameLabel": "Nome da sessão", | ||
"yourNameLabel": "Seu nome" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.LanguageControlSelect { | ||
height: 40px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { render, screen, fireEvent, within } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; // for extended matchers | ||
import { LanguageControl } from './LanguageControl'; | ||
|
||
describe('LanguageControl component', () => { | ||
test('should render with default language', async () => { | ||
render(<LanguageControl />); | ||
|
||
const wrapperNode = screen.getByTestId('language-control'); | ||
const button = await within(wrapperNode).findByRole('button'); | ||
|
||
expect(button).toHaveTextContent('🇺🇸'); | ||
}); | ||
|
||
test('should changes language when selecting a flag option', async () => { | ||
render(<LanguageControl />); | ||
|
||
const wrapperNode = screen.getByTestId('language-control'); | ||
const button = await within(wrapperNode).findByRole('button'); | ||
|
||
fireEvent.mouseDown(button); | ||
|
||
const option = await screen.findByRole('option', { | ||
name: new RegExp('🇧🇷'), | ||
}); | ||
|
||
fireEvent.click(option); | ||
|
||
expect(button).toHaveTextContent('🇧🇷'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import MenuItem from '@material-ui/core/MenuItem'; | ||
import FormControl from '@material-ui/core/FormControl'; | ||
import Select from '@material-ui/core/Select'; | ||
import './LanguageControl.css'; | ||
|
||
import getUnicodeFlagIcon from 'country-flag-icons/unicode'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
export const LanguageControl: React.FC = () => { | ||
const { i18n } = useTranslation(); | ||
const [language, setLanguage] = useState('en-US'); | ||
|
||
useEffect(() => { | ||
setLanguage(i18n.language); | ||
}, [i18n.language]); | ||
|
||
const handleChange = (event: React.ChangeEvent<{ value: unknown }>) => { | ||
setLanguage(event.target.value as string); | ||
i18n.changeLanguage(event.target.value as string); | ||
}; | ||
|
||
return ( | ||
<FormControl variant='outlined'> | ||
<Select | ||
value={language} | ||
onChange={handleChange} | ||
displayEmpty | ||
inputProps={{ 'aria-label': 'Change language' }} | ||
className='LanguageControlSelect' | ||
data-testid='language-control' | ||
> | ||
<MenuItem value={'en-US'}>{getUnicodeFlagIcon('US')}</MenuItem> | ||
<MenuItem value={'pt-BR'}>{getUnicodeFlagIcon('BR')}</MenuItem> | ||
</Select> | ||
</FormControl> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import i18n from 'i18next'; | ||
import Backend from 'i18next-http-backend'; | ||
import LanguageDetector from 'i18next-browser-languagedetector'; | ||
import { initReactI18next } from 'react-i18next'; | ||
|
||
i18n | ||
.use(Backend) | ||
.use(LanguageDetector) | ||
.use(initReactI18next) | ||
.init({ | ||
fallbackLng: 'en-US', | ||
debug: false, | ||
react: { | ||
useSuspense: false, | ||
}, | ||
interpolation: { | ||
escapeValue: false, | ||
}, | ||
}); | ||
|
||
export default i18n; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.