Skip to content

Commit

Permalink
feat: added language changer (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilolutz authored Nov 13, 2021
1 parent 3f00c18 commit cf5e18a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
12 changes: 10 additions & 2 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import React from 'react';
import Translator from './components/i18n/Translator';
import I18n from './components/I18n/I18n';
import Translator from './components/I18n/Translator';

const App: React.FC = () => {
return (
<div><Translator path="home.message" /></div>
<>
<header>
<I18n />
</header>
<div>
<Translator path="home.message" />
</div>
</>
)
}

Expand Down
26 changes: 26 additions & 0 deletions src/app/components/I18n/I18n.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { useTranslation } from 'react-i18next';

const I18n: React.FC = () => {
const { i18n } = useTranslation();

function handleChangeLanguage(language: string) {
i18n.changeLanguage(language);
}

const selectedLanguage = i18n.language;

return (
<div className='langs-container'>
<button type='button' onClick={() => handleChangeLanguage('pt-BR')}>
[pt-br]
</button>
|
<button type='button' onClick={() => handleChangeLanguage('en-US')}>
[en-us]
</button>
</div>
);
};

export default I18n;
File renamed without changes.
12 changes: 0 additions & 12 deletions src/app/components/i18n/.editorconfig

This file was deleted.

0 comments on commit cf5e18a

Please sign in to comment.