diff --git a/app/GoogleTranslate.css b/app/GoogleTranslate.css deleted file mode 100644 index 6e28776..0000000 --- a/app/GoogleTranslate.css +++ /dev/null @@ -1,7 +0,0 @@ -.google-translate-container { - position: absolute; - top: -80px; /* Adjust as needed */ - right: 10px; /* Adjust as needed */ - z-index: 1000; /* Ensure it is above other elements */ - } - \ No newline at end of file diff --git a/app/GoogleTranslate.tsx b/app/GoogleTranslate.tsx index 0b5eb31..ef0a3f3 100644 --- a/app/GoogleTranslate.tsx +++ b/app/GoogleTranslate.tsx @@ -1,36 +1,33 @@ "use client"; import React, { useEffect } from "react"; -import "./GoogleTranslate.css"; // Import the CSS file +import Script from "next/script"; -const GoogleTranslate = () => { - useEffect(() => { - if (!document.getElementById("google_translate_script")) { - const script = document.createElement("script"); - script.type = "text/javascript"; - script.src = "https://translate.google.com/translate_a/element.js?cb=loadGoogleTranslate"; - script.id = "google_translate_script"; - script.onerror = () => console.error('Error loading Google Translate script'); - document.body.appendChild(script); - - (window as any).loadGoogleTranslate = () => { - new (window as any).google.translate.TranslateElement({ - pageLanguage: 'en', - includedLanguages: 'en,hi,pa,sa,mr,ur,bn,es,fr,de,it', - layout: (window as any).google.translate.TranslateElement.InlineLayout.SIMPLE, - }, 'google_element'); - }; - } - return () => { - const script = document.getElementById("google_translate_script"); - if (script) { - document.body.removeChild(script); - } - }; - }, []); +const GoogleTranslate = () => { + return ( +
+
+