0.01
No release in over 3 years
Low commit activity in last 3 years
Language Detection API Client
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Detect Language API Ruby Client

Gem Version Build Status

Detects language of the given text. Returns detected language codes and scores.

Installation

Add this line to your application's Gemfile:

gem 'detect_language'

Upgrading

When upgrading please check changelog for breaking changes.

Configuration

Get your personal API key by signing up at https://detectlanguage.com

DetectLanguage.configure do |config|
  config.api_key = 'YOUR API KEY'
end

Usage

Detect language

DetectLanguage.detect('Dolce far niente')

Result

[{"language" => "it", "score" => 0.5074}]

Detect single code

If you need just a language code you can use detect_code.

DetectLanguage.detect_code('Dolce far niente')

Result

"it"

Batch detection

It is possible to detect language of several texts with one request. This method is significantly faster than doing one request per text. To use batch detection just pass array of texts to detect_batch method.

DetectLanguage.detect_batch(['Dolce far niente', 'Labas rytas'])

Result

Result is array of detections in the same order as the texts were passed.

[[{"language" => "it", "score" => 0.5074}], [{"language" => "lt", "score" => 0.3063}]]

Get your account status

DetectLanguage.account_status

Result

{"date"=>"2013-11-17", "requests"=>95, "bytes"=>2223, "plan"=>"FREE", "plan_expires"=>nil,
 "daily_requests_limit"=>5000, "daily_bytes_limit"=>1048576, "status"=>"ACTIVE"}

Get list of supported languages

DetectLanguage.languages

Result

Array of language codes and names.

License

Detect Language API Client is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.