Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repositioned google translate from top to footer #699

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@
font-family: Arial, sans-serif;
}

#translate-container {
position: fixed;
top: 80px; /* Adjust this value to move the box down from the top */
left: 20px; /* Keeps the box aligned to the left */
background: #fff;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
z-index: 1000;
}

/* Optional: Add a dark mode for your website */
.dark-mode {
background-color: #343434;
Expand All @@ -42,15 +30,7 @@
</head>
<body>
<div id="root"></div>
<div id="translate-container">
<div id="google_translate_element"></div>
</div>
<script type="module" src="/src/main.jsx"></script>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script id="google-translate-script" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit" async></script>
</body>
</html>
18 changes: 17 additions & 1 deletion src/Components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,29 @@ import { scroller } from "react-scroll";
import Visitors from "../Visitors";
import { AiFillHome, AiFillInfoCircle, AiFillPhone, AiFillQuestionCircle, AiFillLock, AiFillFileText } from "react-icons/ai";
import { BiBook, BiSupport, BiCommentDetail, BiBriefcase, BiGroup } from "react-icons/bi";
import GoogleTranslateComponent from "../GoogleTranslate/GoogleTranslate";

const Footer = () => {
const [sticky, setSticky] = useState(false);
const [mobileMenu, setMobileMenu] = useState(false);
const navigate = useNavigate();



useEffect(() => {


const handleScroll = () => {
setSticky(window.scrollY > 200);
};

window.addEventListener("scroll", handleScroll);
return () => {
window.removeEventListener("scroll", handleScroll);
};
}, []);


const toggleMenu = () => {
setMobileMenu(!mobileMenu);
};
Expand Down Expand Up @@ -99,6 +105,16 @@ const Footer = () => {
</a>
<li className="footer-link"><AiFillPhone className="footer-icon" /> Media</li>
</ul>



{/* <div id="translate-container">
<div id="google_translate_element"></div>
</div> */}
<GoogleTranslateComponent />



</div>
<div className="footer-2">
<p className="footer-section-title">Need Help</p>
Expand Down
32 changes: 32 additions & 0 deletions src/Components/GoogleTranslate/GoogleTranslate.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { useEffect, useRef } from "react";

const TranslateComponent = () => {
const googleTranslateRef = useRef(null);

useEffect(() => {
let intervalId = null;
const checkGoogleTranslate = () => {
if (window.google && window.google.translate && window.google.translate.TranslateElement.InlineLayout) {
clearInterval(intervalId);
new window.google.translate.TranslateElement(
{
pageLanguage: "en",
includedLanguages: "af,ach,ak,am,ar,az,be,bem,bg,bh,bn,br,bs,ca,chr,ckb,co,crs,cs,cy,da,de,ee,el,en,eo,es,es-419,et,eu,fa,fi,fo,fr,fy,ga,gaa,gd,gl,gn,gu,ha,haw,hi,hr,ht,hu,hy,ia,id,ig,is,it,iw,ja,jw,ka,kg,kk,km,kn,ko,kri,ku,ky,la,lg,ln,lo,loz,lt,lua,lv,mfe,mg,mi,mk,ml,mn,mo,mr,ms,mt,ne,nl,nn,no,nso,ny,nyn,oc,om,or,pa,pcm,pl,ps,pt-BR,pt-PT,qu,rm,rn,ro,ru,rw,sd,sh,si,sk,sl,sn,so,sq,sr,sr-ME,st,su,sv,sw,ta,te,tg,th,ti,tk,tl,tn,to,tr,tt,tum,tw,ug,uk,ur,uz,vi,wo,xh,yi,yo,zh-CN,zh-TW,zu",
layout: window.google.translate.TranslateElement.InlineLayout.VERTICAL
},
googleTranslateRef.current
);
}
};
intervalId = setInterval(checkGoogleTranslate, 100);
return () => clearInterval(intervalId);
}, []);

return (
<div>
<div ref={googleTranslateRef}></div>
</div>
);
};

export default TranslateComponent;
11 changes: 11 additions & 0 deletions src/Components/GoogleTranslate/googleTranslate.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#translate-container {
/* position: fixed; */
height: 100px;
width: 300px;
background: #fff;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
z-index: 1000;
}