Translation API Introduction
Using online translation websites like Google Translate and DeepL is very convenient. However, if you want to integrate these services into your website or applications for language translation, you’ll need to use their translation APIs.
Google Translate API
For example, Google offers a unified Cloud Translation API client library for Node.js that supports both Cloud Translation - Advanced and Cloud Translation - Basic. This library allows for easy invocation of the API in many languages. Additionally, Google provides a Node.js library for seamless integration.
|
|
Google Cloud Translation API uses Google’s neural machine translation technology to let you dynamically translate text through the API using a Google pre-trained, custom model, or a translation specialized large language model (LLMs).
It comes in Basic and Advanced editions. Both provide fast and dynamic translation, but Advanced offers customization features, such as domain-specific translation, formatted document translation, and batch translation.
The first 500,000 characters sent to the API to process (Basic and Advanced combined) per month are free (not applicable to LLMs).
|
|
DeepL Translate API
DeepL is a translation tool known for its high-quality, natural-sounding translations. It uses advanced AI to produce better translations than many other services.
Key features:
- High Accuracy: Produces more fluent translations, especially for European languages.
- Languages: Supports many languages like English, German, French, Spanish, and more.
- DeepL Pro: A paid service offering extra features like higher translation limits, better privacy, and file translations.
- Free Version: Offers basic translation on the web or app.
DeepL is popular for its accuracy, speed, and ease of use, making it a favorite for personal and professional translation needs.
DeepL also offers an API with a free tier. The DeepL API Free plan includes a monthly limit of 500,000 characters.
For NodeJS call to DeepL Translate API, you can use as example below:
|
|
LibreTranslate
LibreTranslate is an open-source translation tool that offers a robust alternative to proprietary translation services. It supports multiple languages and provides features such as text translation, language detection, and integration capabilities. Since it is open-source, developers and organizations can customize and host the service on their own servers, ensuring greater control over data privacy and customization options. LibreTranslate is ideal for those seeking a flexible and transparent translation solution.
Additionally, LibreTranslate provides an HTTP interface, making it easy to integrate with other applications.
|
|
However, there is currently no Node.js version available for LibreTranslate.
Consolidate All Translation APIs
You may want to use a single API to call each of the different translation APIs in a unified manner, rather than writing separate code for each one. For this purpose, you can use the NPM package translate, created by Francisco Presencia. This flexible package works with Node.js and the browser using promises. It supports multiple translation services, including Google (default), Yandex, LibreTranslate, and DeepL.
Several translating engines are available to translate your text:
- google: Google Translate.
- yandex: Yandex Translate
- libre: An independent translation engine. You can use the official website or install it on your own server.
- deepl: A rapidly growing popular translation engine built with Machine Learning.
The translate
package integrates translation APIs from various vendors, including Google, DeepL, LibreTranslate, and Yandex. It functions similarly to an official translation API provided by these vendors, requiring an API key for access.
Installation
|
|
NodeJS Example
|
|
You can easily switch the engine
to Google, Yandex, LibreTranslate, or DeepL. By pairing this with the appropriate key for each translation vendor, you can use a unified codebase to call any of these services effortlessly.
Google Translate API Limitation
Sometimes, you may want to try a free and unlimited API for Google Translate for Node.js. You may try this:
|
|
NodeJS example as below:
|
|
Another version is google-translate-api-x.
|
|
This version is a fork of vitalets/google-translate-api
and includes several improvements. The primary enhancement is its support for both the batch and single Google Translate endpoints, as well as any input request function. Additionally, it offers optional language checking and a list of supported languages. Many similar packages only support the single translate endpoint, which is quickly rate-limited, or the batch translate endpoint, which can sometimes be inaccurate.
DeepL Translate API Limitation
Similar to the Google Translate unlimited version mentioned above for DeepL free trial account, DeepLX is an unlimited version of DeepL. You can find more details at DeepLX’s official site.
Conclusions
To unify the codebase for online translation APIs from different vendors, you can use the Node.js package Translate by Francisco Presencia.
For unlimited Google Translate or DeepL translation APIs for testing purposes, you can refer to google-translate-api-x
or DeepLX
.
References
- Google translate API document
- NPM Package: Translate package on node.js and the browser with promises by Francisco Presencia