Skip to content

Instantly share code, notes, and snippets.

@yashnirmal
Last active April 1, 2023 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yashnirmal/282c9e69d13bb2667620d5d94eb631b1 to your computer and use it in GitHub Desktop.
Save yashnirmal/282c9e69d13bb2667620d5d94eb631b1 to your computer and use it in GitHub Desktop.
Making Multilingual Websites using Google Translate
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Simple Website</title>
<!-- Loading the Google Translate API -->
<script type="text/javascript" defer src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script defer type="text/javascript">
// assigning the element having id 'google_translate_element' to be the Google translate widget and assigning the default language to be English(en)
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>
</head>
<body>
<!-- Below div will act the Google Translate widget -->
<div style="text-align:center" id="google_translate_element"></div>
<h1 style="text-align:center">Simple Multilingual Website</h1>
<h2 style="text-align:center">Like and follow for more!</h2>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment