Google Translate API outputs HTML entities

If you use google translate client lib, you should pass format_ in translate method, not format, it is format_ below are google translate python api: enter image description here


For anyone working in java, there is a format method in Translate.TranslateOption

So right now you might have something translate call like such:

YourTranslateObject.translate(yourTextToBeTranslated,Translate.TranslateOption.targetLanguage(yourTargetLanguageCode))

all you need to do is add a third parameter:

YourTranslateObject.translate(yourTextToBeTranslated,Translate.TranslateOption.targetLanguage(yourTargetLanguageCode), Translate.TranslateOption.format("text"))

since HTML is default, this will switch it to text.


According to the Google Translate documentation, you can choose which format you will provide the text which is to be translated (see format in query parameters). The format defaults to HTML if not specfied.

You should set this query parameter to text to indicate that you are sending plain-text as Google will likely return the translated text in the same format as it is received.

So your PHP code could become:

$baseUrl = "https://www.googleapis.com/language/translate/v2";
$params ="?key=$api_key&q=$value&source=en&target=$language_key&format=text";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $baseUrl + $params );