Step 1- Add a div<> element on the layout master page to show the language selection dropdown list.
<div id="google_translate_element" style="margin-top: 10px;"></div>
Step 2- Copy and paste bellow gave script on the master layout page
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
}
</script>
Step -3 Run your application/Website and enjoy Google content Translation service on your website
Complete example :-
<!DOCTYPE
html>
<html
lang="en-US">
<body>
<h1>My
first Web Page</h1>
<h1>Nitin
Chauhan</h1>
<p>Nitin
Kumar , Rahul Kumar , Prashant kumar ,…:</p>
<div
id="google_translate_element"></div>
<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>
<p>
Translate the content of this page by selecting a language in the select
box.</p>
</body></html>
|