Google Translate API outputs HTML entities

前端 未结 4 2053
小蘑菇
小蘑菇 2021-01-18 00:52

ENGLISH: Sale ID prefix is a required field

FRENCH: Vente préfixe d'ID est un champ obligatoire

Is there a way to have goog

4条回答
  •  天涯浪人
    2021-01-18 01:12

    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 );
    

提交回复
热议问题