Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6572377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:59:51+00:00 2026-05-25T14:59:51+00:00

I want to translate my website using Google Translate . I used the code

  • 0

I want to translate my website using Google Translate. I used the code below.

<div id="google_translate_element"></div><script>
function googleTranslateElementInit() {
    new google.translate.TranslateElement({
        pageLanguage: 'en'
    }, 'google_translate_element');
}
</script><script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>

It is working fine with text of the website, but does not translate the text box, text area’s text. Is there a solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T14:59:51+00:00Added an answer on May 25, 2026 at 2:59 pm

    You could iterate through the elements in your page and make individual ajax calls to Google Translate API to translate them one by one and them replace the textbox/textarea values.

    Using jQuery, you can iterate through your textbox, textareas and everything else you want to. The code should be something like:

    $('input:text').each(function(index) {
    
        var elementId = $(this).attr("id"); 
    
        //Call the Google API
        $.ajax({
            type : "GET",
            url : "https://ajax.googleapis.com/ajax/services/language/translate",
            dataType : 'jsonp',
            cache: false,
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            data : "v=1.0&q="+$("#"+elementId).val()+"&langpair=en|es",
            success : function(iData){
                //update the value
                $("#"+elementId).val(iData["responseData"]["translatedText"]);      
            },
            error:function (xhr, ajaxOptions, thrownError){ }
        });
    });
    

    As you can see, the parameter &langpair=en|es asks to translate from English to Spanish.

    Just remember that one call will be made for each <input type="text".../>, so you might want to add some kind of validation to filter useless calls! You might also want to validate Google’s answer.

    Here is a link in order to understand the kind of response Google will send you:
    http://code.google.com/apis/language/translate/v1/using_rest_translate.html

    EDIT: Since free use of Google’s API will be shut down on 2011-12-01, you could use Apertium. The call and response is almost the same: http://api.apertium.org/json/translate?q=hello%20world&langpair=en|es

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to execute this script (view source) that uses Google Translate AJAX API
I'm adding Google Translate links to my website, but I want to run some
I want to translate my text into device language. So I tried below code
I have an C# function which i want to translate in Java code. I
Here's my code: sentenceToTranslate = raw_input(Please write in the sentence you want to translate:
I have a website with Dutch text which I want to translate to English.
Here is the Java code which I want to translate to C#: public Enumeration
I want to translate this var db = new PracticeEntities(); var destinations = db.DestinationDetails.
I want to switch from my app to a web site (http://translate.google.com/) just clicking
I'm writing a website using JSP. I want to have the website available in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.