@@ -3,9 +3,8 @@ import { useState, useEffect } from "preact/hooks"
33import MailchimpSubscribe from "react-mailchimp-subscribe"
44import SubscribeSvg from "~/assets/svgs/footer/subscribe.svg?react"
55import { clsx } from "~/lib"
6- import i18next , { changeLanguage , t } from "i18next"
7-
8-
6+ import { t } from "i18next"
7+ import { useI18n } from "~/hooks/useI18n"
98import EmailInput from "./EmailInput.tsx"
109import styles from "./Subscribe.module.css"
1110
@@ -20,8 +19,8 @@ export default function Subscribe(props) {
2019 const [ email , setEmail ] = useState ( "" )
2120 const [ customMessage , setCustomMessage ] = useState ( "" )
2221 const [ emailValid , setEmailValid ] = useState ( false )
23-
24- i18next . changeLanguage ( props . lang )
22+ // Use the hook to ensure i18next is initialized and handle language changes
23+ useI18n ( props . lang )
2524
2625 useEffect ( ( ) => {
2726 setCustomMessage ( "" )
@@ -51,22 +50,28 @@ export default function Subscribe(props) {
5150 </ span >
5251
5352 < div className = { styles . copyBox } >
54- < div className = { styles . subscribeTitle } > { t ( "landing.NewsletterCTA.title" ) } </ div >
55- < div className = { styles . subscribeText } >
56- { t ( "landing.NewsletterCTA.text" ) }
57- </ div >
53+ < div className = { styles . subscribeTitle } > { t ( "landing.NewsletterCTA.title" ) } </ div >
54+ < div className = { styles . subscribeText } > { t ( "landing.NewsletterCTA.text" ) } </ div >
5855 </ div >
5956 < MailchimpSubscribe
6057 url = { url }
61- render = { ( { subscribe, status, message } : any ) => (
58+ render = { ( {
59+ subscribe,
60+ status,
61+ message,
62+ } : {
63+ subscribe : ( data : { EMAIL : string } ) => void
64+ status : string
65+ message : string
66+ } ) => (
6267 < div className = { styles . emailBox } >
6368 < EmailInput
6469 className = { styles . emailInput }
6570 value = { email }
6671 onChange = { handleChangeEmail }
6772 onClick = { ( ) => handleSubmit ( subscribe ) }
6873 onEnter = { ( ) => handleSubmit ( subscribe ) }
69- placeholder = { t ( "landing.NewsletterCTA.placeholder" ) }
74+ placeholder = { t ( "landing.NewsletterCTA.placeholder" ) }
7075 end = { status === "success" }
7176 />
7277 { customMessage && < div className = { styles . errorMessage } > { customMessage } </ div > }
0 commit comments