What You Need To Add Language Detection To Your Apps
Wouldn’t it be nice to enhance your app with automatic language detection support for 173 languages? The Languagelayer is a simple and powerful REST API built to efficiently match text of any length to its corresponding language, cross-referencing single words, expressions and grammatical constructions, as well as taking into account any existing accents, dialects and other linguistic deviations. In this article we will see how fast and easy it is to use RAD Studio and Delphi to create a FireMonkey multidevice application using the LowCode Wizard in addition to a REST client library to take advantage of LanguageLayer API API and retrieve a JSON format response for automate language detection in real-time. Our RAD Studio and Delphi applications will be able to call the API and request information based on the name of parameters you provide. How do I set up the LanguageLayer API? Make sure you refer to LanguageLayer API website (https://LanguageLayer.com/) and and sign up for the free Plan (20 Requests/minute) providing only your email and some basic information (no credit card required). Once you are in the website will redirect you to a Quickstart guide dashboard and your API Access Key will be provided. The Access Key unique, personal and is required to authenticate with the API. Keep it safe! How do I call LanguageLayer API endpoints? Now all we need to do is to call the API base URL (http://api.languageLayer.com/) via a HTTP POST method with no JSON request body needed and some few requested parameters added to the URL address depending on the endpoint we choose to call. One can do that using REST Client libraries available on several programming languages. languageLayer offers one API endpoints to choose from: Detect: Will return information regarding the language of the query passed as parameter For a complete and detailed list of endpoints and its parameters make sure you refer to LanguageLayer Quickstart guide (https://languageLayer.com/quickstart) http://api.languageLayer.com/detect ? access_key = YOUR_ACCESS_KEY & query = I%20like%20apples%20%26%20oranges. // more parameters available please refer to the API Documentation (https://languageLayer.com/documentation) http://api.languageLayer.com/detect ? access_key = YOUR_ACCESS_KEY & query = I%20like%20apples%20%26%20oranges. // more parameters available please refer to the API Documentation (https://languageLayer.com/documentation) What does the LanguageLayer API endpoint return? After the call the main results will be as shown below. The languageLayer API’s live endpoint is used to get the latest rates for all available or a specific set of currencies. URL encoding is required in order to send the query text this means that a text like “I like apples & oranges.” should be passed as “I%20like%20apples%20%26%20oranges.”. { “success”: true, “results”: [{ “language_code”: “en”, “language_name”: “English”, “probability”: 83.896703655741, “percentage”: 100, “reliable_result”: true }]} { “success”: true, “results”: [{ “language_code”: “en”, “language_name”: “English”, “probability”: 83.896703655741, “percentage”: 100, “reliable_result”: true }]} How do I connect my applications to LanguageLayer API? Once you have followed basic steps to set up the LanguageLayer API we need to make sure we are able to connect and communicate with it before we start writing some code. RAD Studio Delphi and C++Builder make it very easy to connect to APIs as you can you REST Debugger to automatically create the REST components and paste them into your app. In Delphi all the job is done using 3 components tot make the API call. They are the TRESTClient, TRESTRequest, and TRESTResponse. Once […]
