@@ -13,10 +13,11 @@ import {
1313} from '@heroui/react'
1414import { PasswordInput } from '@renderer/components/PasswordInput'
1515import { useToggle } from 'ahooks'
16- import { useState } from 'react'
16+ import { useState , useEffect } from 'react'
1717import { GoPlus } from 'react-icons/go'
1818import { IoIosEye , IoIosEyeOff } from 'react-icons/io'
1919import { MdOutlineContentCopy } from 'react-icons/md'
20+ import { useTranslation } from 'react-i18next'
2021import { useWallet } from '../wallets/WalletContext'
2122
2223const WALLET_PASSWORD_REGEX = / ^ (? = .* [ A - Z a - z ] ) (? = .* \d ) [ A - Z a - z \d ] { 8 , } /
@@ -34,6 +35,12 @@ export const CreateWalletModal = () => {
3435 const [ walletName , setWalletName ] = useState ( '' )
3536 const [ mnemonic , setMnemonic ] = useState ( '' )
3637 const [ showMnemonic , { toggle : toggleShowMnemonic } ] = useToggle ( false )
38+ const { t, i18n } = useTranslation ( )
39+ const [ continueText , setContinueText ] = useState ( t ( 'common.continue' ) )
40+
41+ useEffect ( ( ) => {
42+ setContinueText ( t ( 'common.continue' ) )
43+ } , [ i18n . language , t ] )
3744
3845 const onSubmit = async ( e : React . FormEvent < HTMLFormElement > ) => {
3946 e . preventDefault ( )
@@ -42,8 +49,8 @@ export const CreateWalletModal = () => {
4249
4350 if ( password !== passwordConfirm ) {
4451 addToast ( {
45- title : 'Mismatched Passwords' ,
46- description : 'Passwords do not match' ,
52+ title : t ( 'toasts.passwordMismatch.title' ) ,
53+ description : t ( 'toasts.passwordMismatch.description' ) ,
4754 color : 'danger' ,
4855 } )
4956 return
@@ -56,8 +63,8 @@ export const CreateWalletModal = () => {
5663 setPassword ( password )
5764 } catch ( error ) {
5865 addToast ( {
59- title : 'Error' ,
60- description : 'Failed to generate mnemonic' ,
66+ title : t ( 'toasts.generateError.title' ) ,
67+ description : t ( 'toasts.generateError.description' ) ,
6168 color : 'danger' ,
6269 } )
6370 }
@@ -66,8 +73,8 @@ export const CreateWalletModal = () => {
6673 const handleCopy = async ( ) => {
6774 await navigator . clipboard . writeText ( mnemonic )
6875 addToast ( {
69- title : 'Copied' ,
70- description : 'Mnemonic copied to clipboard' ,
76+ title : t ( 'toasts.copied.title' ) ,
77+ description : t ( 'toasts. copied.description' ) ,
7178 color : 'success' ,
7279 } )
7380 }
@@ -83,8 +90,8 @@ export const CreateWalletModal = () => {
8390 await window . dbAPI . insertWallet ( walletName , address , encrypted , salt )
8491
8592 addToast ( {
86- title : 'Wallet Created' ,
87- description : 'Your wallet has been created successfully' ,
93+ title : t ( 'toasts.walletCreated.title' ) ,
94+ description : t ( 'toasts.walletCreated.description' ) ,
8895 color : 'success' ,
8996 } )
9097 setMnemonic ( '' )
@@ -95,8 +102,8 @@ export const CreateWalletModal = () => {
95102 onClose ( )
96103 } catch ( error ) {
97104 addToast ( {
98- title : 'Error' ,
99- description : 'Failed to create wallet' ,
105+ title : t ( 'toasts.creationFailed.title' ) ,
106+ description : t ( 'toasts.creationFailed.description' ) ,
100107 color : 'danger' ,
101108 } )
102109 }
@@ -113,7 +120,7 @@ export const CreateWalletModal = () => {
113120 'linear-gradient(176.63deg, #725DFD -33.88%, #3E3384 111.03%)' ,
114121 } }
115122 >
116- Create Wallet
123+ { t ( 'common.createWallet' ) }
117124 </ Button >
118125
119126 < Modal
@@ -126,9 +133,9 @@ export const CreateWalletModal = () => {
126133 < ModalContent >
127134 < div className = "space-y-12 px-12 py-12" >
128135 < ModalHeader className = "block space-y-6 text-center" >
129- < h3 className = "text-[28px]" > Create Wallet </ h3 >
136+ < h3 className = "text-[28px]" > { t ( 'createWallet.title' ) } </ h3 >
130137 < p className = "text-lg font-normal text-default-400" >
131- Create a new wallet to manage your WART tokens
138+ { t ( 'createWallet.description' ) }
132139 </ p >
133140 </ ModalHeader >
134141
@@ -141,7 +148,7 @@ export const CreateWalletModal = () => {
141148 >
142149 < Input
143150 name = "name"
144- label = "Wallet Name"
151+ label = { t ( 'common.walletName' ) }
145152 labelPlacement = "outside"
146153 isRequired
147154 size = "lg"
@@ -151,21 +158,21 @@ export const CreateWalletModal = () => {
151158 />
152159 < PasswordInput
153160 name = "password"
154- label = "Password"
161+ label = { t ( 'common.password' ) }
155162 labelPlacement = "outside"
156163 isRequired
157164 size = "lg"
158165 validate = { ( value ) =>
159166 ! WALLET_PASSWORD_REGEX . test ( value )
160- ? 'Invalid password format'
167+ ? t ( 'createWallet.invalidPassword' )
161168 : undefined
162169 }
163170 variant = "faded"
164171 classNames = { { inputWrapper : 'bg-default-200' } }
165172 />
166173 < PasswordInput
167174 name = "passwordConfirm"
168- label = "Confirm Password"
175+ label = { t ( 'common.confirmPassword' ) }
169176 labelPlacement = "outside"
170177 isRequired
171178 size = "lg"
@@ -177,7 +184,7 @@ export const CreateWalletModal = () => {
177184 ) : (
178185 < ModalBody >
179186 < p className = "text-center font-bold" >
180- Store your mnemonic safely:
187+ { t ( 'createWallet.storeMnemonic' ) }
181188 </ p >
182189 < div className = "flex items-center gap-3" >
183190 < Code className = "w-[500px] text-wrap break-words text-base" >
@@ -209,8 +216,7 @@ export const CreateWalletModal = () => {
209216 </ div >
210217 </ div >
211218 < p className = "text-sm font-bold text-warning" >
212- Warning: Lose these words, lose your wallet. Store them
213- safely!
219+ { t ( 'common.warning' ) }
214220 </ p >
215221 </ ModalBody >
216222 ) }
@@ -224,15 +230,15 @@ export const CreateWalletModal = () => {
224230 fullWidth
225231 radius = "sm"
226232 >
227- Create Wallet
233+ { t ( 'common.createWallet' ) }
228234 </ Button >
229235 ) : (
230236 < Button
231237 color = "default"
232238 fullWidth
233239 onPress = { finalizeWalletCreation }
234240 >
235- Continue
241+ { continueText }
236242 </ Button >
237243 ) }
238244 </ ModalFooter >
0 commit comments