From cbb549caa5262cae9d2c99e5cba86f217538c583 Mon Sep 17 00:00:00 2001 From: selvi Date: Mon, 18 Aug 2025 19:37:51 +0530 Subject: [PATCH] contact language updated --- components/ContactFrom/ContactForm.js | 65 +++++++++++++++++++-------- components/Contactpage/Contactpage.js | 33 +++++++------- next-i18next.config.js | 14 +++--- pages/contact/index.js | 2 +- public/locales/en/contact.json | 35 +++++++++++++++ public/locales/es/contact.json | 35 +++++++++++++++ 6 files changed, 141 insertions(+), 43 deletions(-) create mode 100644 public/locales/en/contact.json create mode 100644 public/locales/es/contact.json diff --git a/components/ContactFrom/ContactForm.js b/components/ContactFrom/ContactForm.js index 2597810..b57485e 100644 --- a/components/ContactFrom/ContactForm.js +++ b/components/ContactFrom/ContactForm.js @@ -3,8 +3,11 @@ import React, { useState, useRef } from "react"; import SimpleReactValidator from "simple-react-validator"; import ReCAPTCHA from "react-google-recaptcha"; import axios from "axios"; +import { useTranslation } from 'next-i18next'; const ContactForm = () => { + const { t } = useTranslation("contact"); + const subjectOptions = t("form.subjectOptions", { returnObjects: true }); const [forms, setForms] = useState({ name: "", email: "", @@ -64,7 +67,7 @@ const ContactForm = () => { { headers: { "Content-Type": "application/json" } } ); - alert(response?.data?.message || "Message sent successfully!"); + alert(t("form.successMessage")); setForms({ name: "", @@ -84,7 +87,7 @@ const ContactForm = () => { } setRecaptchaToken(null); } catch (err) { - alert("Failed to send message. Please try again later."); + alert(t("form.failedMessage")); } } else { validator.showMessages(); @@ -103,9 +106,14 @@ const ContactForm = () => { name="name" onBlur={changeHandler} onChange={changeHandler} - placeholder="Your Name" + placeholder={t("form.namePlaceholder")} /> - {validator.message("name", forms.name, "required|alpha_space")} + {validator.message( + "name", + forms.name, + "required|alpha_space", + { messages: { required: t("form.requiredMessages.name") } } + )} @@ -117,9 +125,14 @@ const ContactForm = () => { name="email" onBlur={changeHandler} onChange={changeHandler} - placeholder="Your Email" + placeholder={t("form.emailPlaceholder")} /> - {validator.message("email", forms.email, "required|email")} + {validator.message( + "email", + forms.email, + "required|email", + { messages: { required: t("form.requiredMessages.email") } } + )} @@ -131,9 +144,14 @@ const ContactForm = () => { name="phone" onBlur={changeHandler} onChange={changeHandler} - placeholder="Your phone" + placeholder={t("form.phonePlaceholder")} /> - {validator.message("phone", forms.phone, "required|phone")} + {validator.message( + "phone", + forms.phone, + "required|phone", + { messages: { required: t("form.requiredMessages.phone") } } + )} @@ -145,26 +163,37 @@ const ContactForm = () => { value={forms.subject} name="subject" > - - - - - - + + {Array.isArray(subjectOptions) && + subjectOptions.map((opt, idx) => ( + + ))} - {validator.message("subject", forms.subject, "required")} + + {validator.message( + "subject", + forms.subject, + "required", + { messages: { required: t("form.requiredMessages.subject") } } + )} +
- {validator.message("message", forms.message, "required")} + {validator.message( + "message", + forms.message, + "required", + { messages: { required: t("form.requiredMessages.message") } } + )}
@@ -178,7 +207,7 @@ const ContactForm = () => {
diff --git a/components/Contactpage/Contactpage.js b/components/Contactpage/Contactpage.js index 1c5f4af..59ee799 100644 --- a/components/Contactpage/Contactpage.js +++ b/components/Contactpage/Contactpage.js @@ -1,10 +1,11 @@ import React from 'react'; import ContactForm from '../ContactFrom/ContactForm' +import { useTranslation } from 'next-i18next'; const Contactpage = () => { - - return( + const { t } = useTranslation("contact"); + return (
@@ -32,12 +33,11 @@ const Contactpage = () => {
-

Email Us

-

info@janahanlaw.com

- {/*

helloyou@gmail.com

*/} +

{t("contactInfo.emailTitle")}

+

{t("contactInfo.email")}

- +
@@ -46,32 +46,31 @@ const Contactpage = () => {
-

Call Now

-

+1 (305) 330-7413

- {/*

+1 800 123 654 987

*/} +

{t("contactInfo.callTitle")}

+

{t("contactInfo.phone")}

- +
-

Have Any Question?

-

We’re here to help with all your U.S. immigration and legal needs — contact Janahan Law for trusted guidance today.

+

{t('contactInfo.questionTitle')}

+

{t('contactInfo.questionDesc')}

- +
- + - + {/*
*/} - ) - + ) + } export default Contactpage; diff --git a/next-i18next.config.js b/next-i18next.config.js index 2eb1d60..64c0762 100644 --- a/next-i18next.config.js +++ b/next-i18next.config.js @@ -1,4 +1,4 @@ -const { default: OurApproach } = require("./pages/our-approach"); +// const { default: OurApproach } = require("./pages/our-approach"); module.exports = { i18n: { @@ -6,18 +6,18 @@ module.exports = { locales: ['en', 'es'], localeDetection: false, }, - ns: ['common', 'menu', 'homeHero', 'home4Card'], + ns: ['common', 'menu', 'homeHero', 'home4Card', '(home)/homeAbout', '(home)/homeFeature', '(home)/testimonial', '(home)/homeCalltoAction', 'ourMission', 'racialJustice', 'contact', 'ourApproach', 'ourStory', 'aboutService', 'aboutMission', 'aboutRacial', 'aboutDonor' ], defaultNS: 'common', // localePath: './public/locales', }; -// aakash - 'ourMission', 'racialJustice' +// aakash - ourMission, racialJustice -// Selvi - 'ourStory', 'aboutService', 'aboutMission', 'aboutRacial', 'aboutDonor' +// Selvi - 'ourStory', 'aboutService', 'aboutMission', 'aboutRacial', 'aboutDonor' -// Vidhya - OurApproach - -// Alagu Raj - 'common', 'menu', 'homeHero', 'home4Card', '(home)/homeAbout', '(home)/homeFeature', '(home)/testimonial', '(home)/homeCalltoAction' +// Vidhya +// OurApproach +// Alagu Raj - 'common', 'menu', 'homeHero', 'home4Card', '(home)/homeAbout', '(home)/homeFeature', '(home)/testimonial', '(home)/homeCalltoAction' \ No newline at end of file diff --git a/pages/contact/index.js b/pages/contact/index.js index c0e970d..a5371e5 100644 --- a/pages/contact/index.js +++ b/pages/contact/index.js @@ -24,7 +24,7 @@ export default ContactPage; export async function getStaticProps({ locale }) { return { props: { - ...(await serverSideTranslations(locale, ['common', 'menu'])), // Add 'home', 'footer', etc. if needed + ...(await serverSideTranslations(locale, ['common', 'menu', 'contact'])), // Add 'home', 'footer', etc. if needed }, }; } diff --git a/public/locales/en/contact.json b/public/locales/en/contact.json new file mode 100644 index 0000000..ce08902 --- /dev/null +++ b/public/locales/en/contact.json @@ -0,0 +1,35 @@ +{ + "contactInfo": { + "emailTitle": "Email Us", + "email": "info@janahanlaw.com", + "callTitle": "Call Now", + "phone": "+1 (305) 330-7413", + "questionTitle": "Have Any Question?", + "questionDesc": "We’re here to help with all your U.S. immigration and legal needs — contact Janahan Law for trusted guidance today." + }, + "form": { + "namePlaceholder": "Your Name", + "emailPlaceholder": "Your Email", + "phonePlaceholder": "Your Phone", + "subjectPlaceholder": "Select Subject", + "subjectOptions": [ + "River Development", + "Village Development", + "Road Development", + "Town Development", + "Social Development" + ], + "messagePlaceholder": "Message", + "submitButton": "Submit Now", + "successMessage": "Message sent successfully!", + "failedMessage": "Failed to send message. Please try again later.", + "requiredMessages": { + "name": "Name is required", + "email": "Valid email is required", + "phone": "Phone number is required", + "subject": "Please select a subject", + "message": "Message is required", + "recaptcha": "Please complete the ReCAPTCHA" + } + } +} diff --git a/public/locales/es/contact.json b/public/locales/es/contact.json new file mode 100644 index 0000000..564bd7f --- /dev/null +++ b/public/locales/es/contact.json @@ -0,0 +1,35 @@ +{ + "contactInfo": { + "emailTitle": "Envíanos un correo", + "email": "info@janahanlaw.com", + "callTitle": "Llama ahora", + "phone": "+1 (305) 330-7413", + "questionTitle": "¿Tienes alguna pregunta?", + "questionDesc": "Estamos aquí para ayudarte con todas tus necesidades legales y de inmigración en EE. UU. — contacta a Janahan Law para obtener orientación confiable hoy." + }, + "form": { + "namePlaceholder": "Tu Nombre", + "emailPlaceholder": "Tu Correo Electrónico", + "phonePlaceholder": "Tu Teléfono", + "subjectPlaceholder": "Selecciona Asunto", + "subjectOptions": [ + "Desarrollo de Ríos", + "Desarrollo de Aldeas", + "Desarrollo de Carreteras", + "Desarrollo de Ciudades", + "Desarrollo Social" + ], + "messagePlaceholder": "Mensaje", + "submitButton": "Enviar Ahora", + "successMessage": "¡Mensaje enviado con éxito!", + "failedMessage": "Error al enviar el mensaje. Por favor, inténtalo de nuevo más tarde.", + "requiredMessages": { + "name": "El nombre es obligatorio", + "email": "Correo electrónico válido es obligatorio", + "phone": "El teléfono es obligatorio", + "subject": "Por favor selecciona un asunto", + "message": "El mensaje es obligatorio", + "recaptcha": "Por favor completa el ReCAPTCHA" + } + } +}