

Today, we’re introducing a paid version of the Google Translate API for businesses and commercial software developers. We are dynamically adding a script to head, So when the request is successful showIt() function called.Back in May, we announced the deprecation of the free Translate API v1. In the URL Request, we can pass the callback parameter, so callback function will be invoked if the request is successful. To use Translate API in JavaScript, you need to get “API Key” from Google API. – 500 (Internal Server Error) – Google cannot identify the source language of your text or another error occurred. – 403 (Forbidden) – you have entered an incorrect API key or have exceeded your quota, – 400 (Bad request) – your request is missing some parameters or you have passed wrong values to the parameters present in the request (e.g. The Google Translate API can return the following error codes: when the source text was too short) and the Google Translate API will return an HTTP 500 error. The source language will not be successfully detected (e.g. Google will manage to detect the language by itself, the JSON response will consequently contain an additional detectedSourceLanguage property holding the source language code.Ģ. What happens if you don’t set the source language?ġ. – source – the source language (if it’s not specified, Google will try to identify it automatically), The translate method has several parameters. It is accessible under the following URL: The core functionality of the Google Translate API is available through its translate method. To do this we will refer to the following URL: Translate and detect services are charged, but we can use the third option-languages-just to test if our application will connect to the API. Remember you need to transfer your API key as a key parameter in every call. The parameters passed on to each process must be encoded with URLs which can be done in PHP using the function rawurlencode().

A simple way to make such a request in PHP is to use the cURL library which we will use in the following examples. – languages, which lists the source and target languages supported by the API.Īll methods will be called by getting requests. – detect, which detects the language of the given text,


– translate, which translates the given text from one language to another, Step-3: GOOGLE TRANSLATE API PHP EXAMPLE. To use the API you need get a Google API key Step-1: Go to Cloud Console Step-2: Create a Project and select it.
