From 1f366767768251d7e47d7ba88902bb1e64adda49 Mon Sep 17 00:00:00 2001 From: Ojas Arora <127867874+Ojas-Arora@users.noreply.github.com> Date: Tue, 30 Jul 2024 20:02:38 +0530 Subject: [PATCH] Multilanguage --- src/components/Footer/Footer.jsx | 31 +++++++++++++++++++++++++++++-- src/components/Navbar/Navbar.jsx | 26 -------------------------- 2 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/components/Footer/Footer.jsx b/src/components/Footer/Footer.jsx index 0393d07..24659e8 100644 --- a/src/components/Footer/Footer.jsx +++ b/src/components/Footer/Footer.jsx @@ -1,8 +1,34 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import img from '../../assets/logo_white.png'; function Footer() { const currentYear = new Date().getFullYear(); + + useEffect(() => { + const script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = 'https://translate.google.com/translate_a/element.js?cb=loadGoogleTranslate'; + script.onerror = function () { + console.error('Error loading Google Translate script'); + }; + document.body.appendChild(script); + + window.loadGoogleTranslate = function () { + new window.google.translate.TranslateElement( + { + pageLanguage: 'en', + includedLanguages: 'en,hi,pa,sa,mr,ur,bn,es,fr,de,it', + layout: window.google.translate.TranslateElement.InlineLayout.SIMPLE, + }, + 'google_element' + ); + }; + + return () => { + document.body.removeChild(script); + }; + }, []); + return (
); diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx index 02e031b..a6e6510 100644 --- a/src/components/Navbar/Navbar.jsx +++ b/src/components/Navbar/Navbar.jsx @@ -99,29 +99,6 @@ function Navbar() { } }; - useEffect(() => { - const loadGoogleTranslate = () => { - new window.google.translate.TranslateElement( - { - pageLanguage: 'en', - includedLanguages: 'en,hi,pa,sa,mr,ur,bn,es,fr,de,it', - layout: window.google.translate.TranslateElement.InlineLayout.SIMPLE, - }, - 'google_element' - ); - }; - - const script = document.createElement('script'); - script.type = 'text/javascript'; - script.src = 'https://translate.google.com/translate_a/element.js?cb=loadGoogleTranslate'; - script.onerror = () => console.error('Error loading Google Translate script'); - document.body.appendChild(script); - - return () => { - document.body.removeChild(script); - }; - }, []); - return (