4

I need to create a button that will be able to toggle the language of a page's content between French and English.

How can I use the Google Translate API for this?

1 Answer 1

5

Does this help :

<div id="google_translate_element"></div>

<script>
function googleTranslateElementInit() {
  new google.translate.TranslateElement({
    // here is where you change the language
    pageLanguage: 'en'
  }, 'google_translate_element');
}
</script>

<script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

Source

Sign up to request clarification or add additional context in comments.

1 Comment

I am using google translate on https. So i am using https://stgstatdt.s3.amazonaws.com/assets/transliteration.I.js this file. I want toggle language from one to other and vice versa in button click... Please help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.