
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Detects language of given text. Returns detected language codes and scores.
Before using Detect Language API client you have to setup your personal API key. You can get it by signing up at https://detectlanguage.com
Add this line to your application's Gemfile:
gem 'detect_language'
Or install it yourself as:
$ gem install detect_language
If you are using Rails, create initializer config/initializers/detect_language.rb
and add following code there.
Otherwise just integrate following code into your apps configuration.
DetectLanguage.configure do |config|
config.api_key = "YOUR API KEY"
# enable secure mode (SSL) if you are passing sensitive data
# config.secure = true
end
DetectLanguage.detect("Buenos dias señor")
[ {"language"=>"es", "isReliable"=>false, "confidence"=>0.3271028037383178},
{"language"=>"pt", "isReliable"=>false, "confidence"=>0.08356545961002786} ]
If you need just a language code you can use simple_detect
. It returns just the language code.
DetectLanguage.simple_detect("Buenos dias señor")
"es"
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
method.
DetectLanguage.detect(["Buenos dias señor", "Labas rytas"])
Result is array of detections in the same order as the texts were passed.
[ [ {"language"=>"es", "isReliable"=>false, "confidence"=>0.3271028037383178},
{"language"=>"pt", "isReliable"=>false, "confidence"=>0.08356545961002786} ],
[ {"language"=>"lt", "isReliable"=>false, "confidence"=>0.04918032786885246},
{"language"=>"lv", "isReliable"=>false, "confidence"=>0.03350083752093803} ] ]
DetectLanguage.user_status
{"date"=>"2013-11-17", "requests"=>95, "bytes"=>2223, "plan"=>"FREE", "plan_expires"=>nil,
"daily_requests_limit"=>5000, "daily_bytes_limit"=>1048576, "status"=>"ACTIVE"}
DetectLanguage.languages
Array of language codes and names.
Detect Language API Client is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
FAQs
Unknown package
We found that detect_language demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.