Skip to content

Commit

Permalink
Added google translator in footer
Browse files Browse the repository at this point in the history
  • Loading branch information
HishitaGupta committed Jun 30, 2024
1 parent 4c6daca commit 78a67d1
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/components/footer/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,29 @@ const Footer = () => {
{ img: Icon4, header: 'Wide assortment', para: 'Orders $50 or more' },
{ img: Icon5, header: 'Easy returns', para: 'Orders $50 or more' }
];


const addGoogleTranslateScript = () => {
if (!document.getElementById('google-translate-script')) {
const script = document.createElement('script');
script.id = 'google-translate-script';
script.type = 'text/javascript';
script.src = "//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit";
document.body.appendChild(script);
}
};

window.googleTranslateElementInit = () => {
if (!window.googleTranslateElementInitialized) {
new window.google.translate.TranslateElement(
{ pageLanguage: 'en' },
'google_translate_element'
);
window.googleTranslateElementInitialized = true;
}
};

addGoogleTranslateScript();

return (
<>
<section className="newsLetterSection">
Expand Down Expand Up @@ -243,6 +265,7 @@ const Footer = () => {

<h6>Secured Payment Gateways</h6>
<img src={paymentImage} />
<div id="google_translate_element" className="mt-5 p-2 bg-[#2E8B57] rounded-lg shadow-md w-8 h-16"></div>
</div>
</div>

Expand Down

0 comments on commit 78a67d1

Please sign in to comment.