0

i am trying to change the default languge of Google Translate from "Select a Language" to "EN". Unfortunately my jquery is not working. Here is my code. Hope you could help me.

j(' #google_translate_element .goog-te-menu-value span').ready(function (){

     j(this).replaceWith("<span>EN</span>");
     
    });

j(' #google_translate_element .goog-te-menu-value span').each(function (){

     j(this).text("EN")

           });
shadowbudz
  • 231
  • 1
  • 5
  • 17

1 Answers1

0

Google translate uses some cookie called "googtrans" to track and follow the language that is selected. You can set that aforementioned cookie yourself before the pages load and then Google translate will use it.

// PHP code sample, could be accomplished with any language that can set cookies
// set the default language translation to English.
setcookie('googtrans', '/en/en');

example:
setcookie("googtrans", "/en/en", time()+3600, "/", "www.example.com");

Also, adding #googtrans(xx) and append it to the end of the query string will also translate the page for you in the language you prefer automatically, as if you are setting the cookie yourself (where xx is the language code, i.e. en for english - fr for french), etc.

Hopefully it works fine with you :)

Mohab
  • 153
  • 6