1- import React , { useReducer } from 'react' ;
1+ import React , { useCallback , useReducer , useState } from 'react' ;
22
3- import { Button , Dialog , Dropdown , noop } from '@sovryn/ui' ;
3+ import i18next from 'i18next' ;
4+ import { useTranslation } from 'react-i18next' ;
5+
6+ import { Button , Dialog , Dropdown , Menu , MenuItem } from '@sovryn/ui' ;
47
58import { ConnectWalletButton } from '../../2_molecules/ConnectWalletButton/ConnectWalletButton' ;
69import { useTheme } from '../../../hooks/useTheme' ;
710import { useWalletConnect } from '../../../hooks/useWalletConnect' ;
11+ import { translations , languages } from '../../../locales/i18n' ;
812import { AppTheme } from '../../../types/tailwind' ;
913import styles from './App.module.css' ;
1014
1115function App ( ) {
1216 const { handleThemeChange } = useTheme ( ) ;
13-
17+ const { t } = useTranslation ( ) ;
1418 const [ isOpen , toggle ] = useReducer ( p => ! p , false ) ;
1519 const { connectWallet, disconnectWallet, wallets, pending } =
1620 useWalletConnect ( ) ;
1721
22+ const [ currentLang , setCurrentLang ] = useState ( i18next . language ) ;
23+
24+ const changeLanguage = useCallback (
25+ ( lng : string ) => ( ) => {
26+ i18next . changeLanguage ( lng ) ;
27+ setCurrentLang ( lng ) ;
28+ } ,
29+ [ ] ,
30+ ) ;
31+
1832 return (
1933 < div className = "my-2 px-4" >
2034 < header >
@@ -31,18 +45,15 @@ function App() {
3145 < div className = "p-4" > Hello.</ div >
3246 </ Dialog >
3347
34- < Dropdown text = "test" >
35- < div >
36- < div className = "my-2" onClick = { noop } >
37- Dropdown Item 1
38- </ div >
39- < div className = "my-2" onClick = { noop } >
40- Dropdown Item 2
41- </ div >
42- < div className = "my-2" onClick = { noop } >
43- Dropdown Item 3
44- </ div >
45- </ div >
48+ < Dropdown text = { currentLang . toUpperCase ( ) } className = "my-4" >
49+ < Menu >
50+ { languages . map ( lng => (
51+ < MenuItem
52+ text = { lng . toUpperCase ( ) }
53+ onClick = { changeLanguage ( lng ) }
54+ />
55+ ) ) }
56+ </ Menu >
4657 </ Dropdown >
4758
4859 < div className = "flex items-center gap-4" >
@@ -93,6 +104,8 @@ function App() {
93104
94105 < br />
95106 < br />
107+
108+ < p > { t ( translations . wallet ) } </ p >
96109 </ main >
97110 </ div >
98111 ) ;
0 commit comments