Skip to content

Commit

Permalink
MultiLanguage Facility
Browse files Browse the repository at this point in the history
  • Loading branch information
Ojas-Arora committed Jul 30, 2024
1 parent d60ce2e commit 87b8680
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/components/Navbar/Navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,29 @@ 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 (
<nav className="navbar">
<div className="logo">
Expand All @@ -125,6 +148,9 @@ function Navbar() {
<NavLink className={({ isActive }) => ("rem-default " + (isActive ? ' active' : ''))} to="/login">AstroAccess</NavLink>
</li>
{renderContactLink()}
<li className="navbar-list-item" onClick={handleMenuClose}>
<div id="google_element"></div>
</li>
</ul>
</div>
<div className="hamburger" id="hamburger" onClick={toggleMenu} aria-label="Menu">
Expand Down

0 comments on commit 87b8680

Please sign in to comment.