Created
October 5, 2020 03:48
-
-
Save shahmir811/8a68b1f83fe33b8168d0d29e5977be60 to your computer and use it in GitHub Desktop.
App.js file of localization porject
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
import React from 'react'; | |
import './App.css'; | |
import { useTranslation } from 'react-i18next'; | |
function App() { | |
const { t, i18n } = useTranslation(); | |
const handleClick = (lang) => { | |
i18n.changeLanguage(lang); | |
}; | |
return ( | |
<div className="App"> | |
<nav | |
style={{ width: '100%', padding: '2rem 0', backgroundColor: 'grey' }} | |
> | |
<button onClick={() => handleClick('en')}>English</button> | |
<button onClick={() => handleClick('ur')}>Urdu</button> | |
</nav> | |
<h1>{t('Welcome to React js')}</h1> | |
<h1> | |
{t('Thanks.1')} {t('Why.1')} | |
</h1> | |
</div> | |
); | |
} | |
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment