losing leading & trailing space when translated using Google Machine Translation

Posted by Sourabh on Stack Overflow See other posts from Stack Overflow or by Sourabh
Published on 2010-05-22T11:59:09Z Indexed on 2010/05/22 12:00 UTC
Read the original article Hit count: 235

Filed under:
|
|

Hi ,

I am using google ajax based translation API like in the below example.

google.load("language", "1");

    function initialize() {
      var text = document.getElementById("text").innerHTML;
      google.language.detect(text, function(result) {
        if (!result.error && result.language) {
          google.language.translate(text, result.language, "en",
                                    function(result) {
            var translated = document.getElementById("translation");
            if (result.translation) {
              translated.innerHTML = result.translation;
            }
          });
        }
      });
    }
    google.setOnLoadCallback(initialize);

When I send string like " how are you? "

The transaltion what I get is like "xxx xxx xxxxxxx" . the spaces in the original string are trimmed.How do I prevent it from happening ?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about google