Display Only 3 Languages in Google Translate HTML
Asked Answered
F

1

7

I am currently using Google Translate Script Code to convert the text into different languages in my website. However the languages dropdown has many options, I would like to have only 3 Languages ( Kannada, Hindi, English )

Here is the script which i am using

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


  function googleTranslateElementInit() {
    new google.translate.TranslateElement({pageLanguage: 'en'}, 'google_translate_element');
  }

Can anyone please tell me how do i have only Kannda,English and Hindi as Language Options

Fermin answered 10/4, 2020 at 8:5 Comment(1)
You can use this and customize 3 language: github.com/mordadam/google-translate-html-jsPneumatograph
N
21

you need to add includedLanguages in the script like this :

function googleTranslateElementInit() {
    new google.translate.TranslateElement({pageLanguage: 'en' , includedLanguages : 'ar,xx,yy'}, 'google_translate_element');
  }
Nowak answered 10/4, 2020 at 8:26 Comment(3)
function googleTranslateElementInit() { new google.translate.TranslateElement({pageLanguage: 'en',includedLanguages : 'kannada,hindi,english'}, 'google_translate_element'); } I added Like this, But still all the languages are showing up. Do i have to put up two initials that represents kannada hindi and english.? If yes, Where can i get those initials.?Fermin
don't use 'kannada,hindi,english' use their abbreviation. for example : for arabic : arNowak
Thank you! I got it.Fermin

© 2022 - 2024 — McMap. All rights reserved.