How to Detect the Language of Text in Node.JS

Global platforms such as Facebook, Twitter, and more excel in providing accessible user interfacing internationally by allowing users to connect from all over the world. To facilitate this phenomenon within your own platform, providing a way for users to receive and translate text in other languages will support improved user experience and promote your business as capable of incorporating global entities. Furthermore, allowing the following API to detect languages for you will simplify and expedite the process, allowing for instant processing for translation.

Image for post
Image for post

To start our function, we first need to run this command to install the SDK:

npm install cloudmersive-nlp-api-client --save

Or, you can add this snippet to your package.json:

"dependencies": {
"cloudmersive-nlp-api-client": "^2.0.9"

Then, we can call our function:

var CloudmersiveNlpApiClient = require('cloudmersive-nlp-api-client');
var defaultClient = CloudmersiveNlpApiClient.ApiClient.instance;

With that, you can instantly detect foreign languages, including Danish (DAN), German (DEU), English (ENG), French (FRA), Italian (ITA), Japanese (JPN), Korean (KOR), Dutch (NLD), Norwegian (NOR), Portuguese (POR), Russian (RUS), Spanish (SPA), Swedish (SWE), and Chinese (ZHO).

The API Key is available for free and with no commitment on the Cloudmersive website. This gives you access to 800 monthly calls across our library of APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store