Google Translate is one of the earliest language translation services around. Initially available as a web app to detect and translate between languages, Google Translate is now also available as an API. Google Translate API supports over a hundred languages.
Google Translate API is integrated with Rakuten RapidAPI. So you can log on to your Rakuten RapidAPI account to check out the API Console.
In case you don’t have an account on Rakuten RapidAPI, sign up now and get your universal API key to access the Google Translate API and thousands of other APIs hosted on Rakuten Rapid API.
Practical Use Cases of Language Translation
Language Translation finds many applications in business and our day to day lives. Although it is a fun way to learn a new language, there are some practical use cases where it solves real problems for several industries.
Medical transcription mostly deals with converting dictations from doctors to written reports. It is an allied field of the healthcare domain and is a sought after profession. However, transcribing such domain-specific voice memos into multiple different languages at once is not ideal. Hence, the written reports are created only in the primary language, while translations happen based on the request from patients.
This industry produces one of the most voluminous repository of text. Additionally, every case that is taken out for judicial intervention leads to piles of reports, evidence, observations, and statements. Language translation is the most suitable way to help individuals to understand case records when they do not understand the written language.
Government services also produce a lot of forms and other documents to inform citizens about various services. And, there is always a minority expat group under each government jurisdiction who do not follow the local language. An automated form with step-by-step instructions translated in the user’s native language would be a significant step to provide a citizen-friendly service.
Google Translate API is mostly free, and it is quite fast. However, Google Translate API is not very effective in detecting the context of the sentences. Hence it is not recommended for a long strings of text, especially the kind of convoluted language that you read in legal documents.
Let’s take a closer look at the Google Translate API to understand its capabilities.
Overview of Google Translate API
Log on to your Rakuten RapidAPI account and search for “Google Translate”. You can also directly access the Google Translate API console.
The API supports two endpoints, “detect” and “translate”. As the name suggests, one is for detecting the language, and the other is for translating from one language to another.
Under Rakuten RapidAPI, Google Translate API is offered with 50 free API requests in a day.
Click on the “Pricing” tab on API console and subscribe to the BASIC plan to avail the service.
Testing The Google Translate API
Once subscribed, get back to the “Endpoints” tab. Let’s test both the endpoints to get a feel for using the API.
Before you proceed, make sure to check out the supported languages under the “API Details” tab. Here you can see a list of all the languages supported by Google Translate API along with their ISO 638 language code.
Language Detection using Google Translate
The first endpoint is “detect”. Select the endpoint and hit the “Test Endpoint” button with the default inputs.
The default input for the ‘q’ parameter is set to a text in English.
Here is the API response.
The API response returns a JSON object with a key “language” whose value is set to ‘en’ which is the ISO 638 code for English.
You can try the API by setting the ‘q’ parameter with any other language from the list of supported languages.
Language Translation using Google Translate
For translation, select the “translate” endpoint and choose the ‘q’ and ‘target’ parameter, as shown.
As evident, you are translating the text “Hello, world!” into Japanese. Hit “Test Endpoint”, and you should see a response within a few seconds.
You can verify the translated text contained in the “translatedText” key of the JSON response by feeding it into the Google Translate web app or any other online service.
You can further explore the optional parameters defined for the “translate” endpoint.
Of particular interest is the ‘model’ parameter, which accepts a value of “base” (as default, also interpreted as blank value) or “nmt” to select the underlying machine learning model to use for translation. You can try translating the same text by using both the options to see which one results in more accurate translation.
Apart from that, you can specify the format of the input via the ‘format’ parameter. By default, you pass plain text for the ‘q’ parameter, as you have seen in the example above. However, you can also pass the value as ‘html’ to indicate an HTML input text. This is a nifty feature when you want to translate a scraped HTML document from the web. In this case, you directly pass the HTML formatted data from the HTML document instead of extracting the text from HTML and passing that as plain text.
The ‘source’ parameter specifies the source language, which is set to ‘en’ by default. Since the Google Translate API is pretty accurate at detecting the language, you hardly ever have to set this.
Google Translate API In Action
The above example of language translation was too simple for all practical purposes. Let’s try something more relevant to the industries that were covered earlier.
Imagine that you are a medical transcriptionist working amidst the chaos of the Zika virus breakout. Doctors have been summoned by the government to help manage the situation, and they are busy dictating the precautions to make the public aware of the dos and don’ts. You have been tasked to transcribe the doctor’s voice to deliver a written health advisory memo for the city.
Here is a small snippet extracted from the memo that you have written.
____“Zika virus is spread to people mainly through the bite of an infected mosquito. Mosquitoes that spread Zika and other viruses bite during the day and night. The best way to prevent Zika is to protect yourself from mosquito bites.”____
You publish the memo, and all is good until you start getting requests from the public to translate it into Spanish.
Google Translate API comes to your rescue here. Once you run the above text snippet through the “translate” endpoint, you get this result.
Voila! You have done it.
Now, with the help of Google Translate API, you can translate your health advisory memo into many languages without painstakingly translating each word and sentence.
However, beware not take the translated text as final. You must review it before publishing.
Time To Script Your Own Use Case For Google Translate
Now that you have an idea, why not put the Google Translate API to some good use. Think of an application where there is a continually updating textual data being generated by an application and meant for mass consumption. Google Translate can ease your burden of manually translating between languages.
You must check out our Top 10 Translation APIs to know more about similar APIs hosted on Rakuten RapidAPI. You can also check out our translation API collection and see if it suffices your requirements for building text translation features for your project.