title: Different result between google translate website and google translate API client
body: <p>I'm using the google translate API to translate text from Arabic to English and I have had a different result from translating on goolge translate web page and from translating using the API. The feature that google supports for Arabic is Arabizi detection which is available on their website but not using the API. It detects the source language as arabic but doesn't translate it to english.</p>
  
  <p>here is a snapshot of the result on the google translate webpage.</p>
  
  <p><a href="https://i.stack.imgur.com/Q7J58.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q7J58.png" alt="google translate site result"></a></p>
  
  <p>On the other hand, calling the translate api using either the google java library or as a rest client detects the language as arabic but doesn't translate it.</p>
  
  <hr>
  
  <p>The result using the google java client library:</p>
  
  <p>Text: 3awez aro7 3ala el bait
  Detected Language: ar, Confidence: 1.0</p>
  
  <p>Translation from ar to English: 3awez aro7 3ala el bait</p>
  
  <hr>
  
  <p>The json result as a rest client:</p>
  
  <p>Request Body: TranslateReq [query=3awez aro7 3ala el bait, target=ar, model=null]
  JSON Response:</p>
  
  <pre><code>{
    "data": {
      "translations": [
        {
          "translatedText": "3awez aro7 3ala el bait",
          "detectedSourceLanguage": "ar"
        }
      ]
    }
  }
  </code></pre>
  
  <hr>
  
  <p>And below is the code.</p>
  
  <pre><code>package test;
  
  import java.io.IOException;
  
  import org.springframework.http.HttpEntity;
  import org.springframework.http.HttpMethod;
  import org.springframework.http.ResponseEntity;
  
  import com.fasterxml.jackson.annotation.JsonInclude;
  import com.fasterxml.jackson.annotation.JsonProperty;
  import com.google.cloud.translate.Detection;
  import com.google.cloud.translate.Translate;
  import com.google.cloud.translate.Translate.TranslateOption;
  import com.google.cloud.translate.TranslateOptions;
  import com.google.cloud.translate.Translation;
  import com.tagtac.gs.util.rest.RestUtil;
  
  public class TestGooglerTransAPI
  {
  
      public static void main(String[] args) throws IOException
      {
          boolean useGoogleClientLib = true;
          String text = "3awez aro7 3ala el bait"; // The text to translate
  
          if(useGoogleClientLib)
          {
              Translate translate = TranslateOptions.getDefaultInstance().getService();
  
              //Language Detection
              Detection detectedLang = translate.detect(text);
              System.out.printf("Text: %s%n", text);
              System.out.printf("Detected Language: %s, Confidence: %s%n", detectedLang.getLanguage(), detectedLang.getConfidence());
  
              //Translation
              TranslateOption srcLang = TranslateOption.sourceLanguage(detectedLang.getLanguage());
              TranslateOption targetLang = TranslateOption.targetLanguage("en");
              Translation translation = translate.translate(text, srcLang, targetLang);
  
              System.out.printf("Translation from %s to English: %s%n", translation.getSourceLanguage(), translation.getTranslatedText());
          }
          else
          {
              //ReST client
              TranslateReq request = new TranslateReq();
              request.setQuery(text);
              request.setTarget("ar");
              System.out.println("Request Body: " + request);
  
              ResponseEntity&lt;String&gt; resp = 
                      RestUtil.getConfiguredRestTemplate().exchange(
                      "https://translation.googleapis.com/language/translate"
                      + "/v2?key=MY_API_KEY", 
                      HttpMethod.POST, 
                      new HttpEntity&lt;TranslateReq&gt;(request), 
                      String.class);
  
              System.out.printf("JSON Response:%n%s%n", resp.getBody());
          }
      }
  
  
      @JsonInclude(JsonInclude.Include.NON_NULL)
      static class TranslateReq
      {
          @JsonProperty("q")
          private String query;
  
          private String target;
          private String model;
  
          public String getQuery()
          {
              return query;
          }
  
          public void setQuery(String query)
          {
              this.query = query;
          }
  
          public String getTarget()
          {
              return target;
          }
  
          public void setTarget(String target)
          {
              this.target = target;
          }
  
          public String getModel()
          {
              return model;
          }
  
          public void setModel(String model)
          {
              this.model = model;
          }
  
          @Override
          public String toString()
          {
              return "TranslateReq [query=" + query + ", target=" + target + ", model=" + model + "]";
          }
      }
  }
  </code></pre>