Home >Web Front-end >CSS Tutorial >How to Integrate Google Translate into Your Website for Multilingual Content?
Google Translate offers a convenient way to provide multiple language options for your website's content. Two code snippets, found on Google Translate and HTML-5-Tutorial, serve this purpose with slight variations.
The first snippet installs the translation widget without language selection options, while the second includes a customizable select box to allow users to choose their preferred language. However, the second snippet requires some customization to work on both local and live sites.
To implement Google Translate with the second snippet, follow these steps:
<code class="html"><div id="google_translate_element"></div> <script> function googleTranslateElementInit() { new google.translate.TranslateElement( { pageLanguage: 'en' }, 'google_translate_element' ); } </script> <script src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script></code>
With these modifications, the Google Translate widget from HTML-5-Tutorial should function both locally and on a live website, providing your users with seamless language selection and translation options.
The above is the detailed content of How to Integrate Google Translate into Your Website for Multilingual Content?. For more information, please follow other related articles on the PHP Chinese website!