JavaScript wrapper for DetectLanguage Service.
This repository has been discontinued, please go here for an updated version: https://github.com/detectlanguage/detectlanguage-node
npm install detectlanguage [--save]
Before using Detect Language API client you have to setup your personal API key.
You can get it by signing up at http://detectlanguage.com
var DetectLanguage = require('detectlanguage');
var detectLanguage = new DetectLanguage({
key: '[INSERT YOUR KEY HERE]',
ssl: true|false (defaults to TRUE)
});
Takes a simple string and detects the language with a list of detections.
var dataSimple = "I am a Teapot and a Submarine";
detectLanguage.detect(dataSimple, function(error, result) {
console.log(JSON.stringify(result));
});
{
data: {
detections: [
{
language: "en",
isReliable: true,
confidence: 7.85
}
]
}
}
Takes an array simple string and detects the language with a list of detections.
var dataBulk = [
"I am a Teapot and a Submarine",
"Soy una tetera y un submarino",
"Jeg er en tekande og en ubåd"
]
detectLanguage.detect(dataBulk, function(error, result) {
console.log(JSON.stringify(result));
});
{
data: {
detections: [
[
{
language: "en",
isReliable: true,
confidence: 7.85
}
],
[
{
language: "es",
isReliable: true,
confidence: 3.75
}
],
[
{
language: "da",
isReliable: true,
confidence: 4.09
}
]
]
}
}
Returns the list of supported languages.
detectLanguage.languages(function(error, result) {
console.log(JSON.stringify(result));
});
[
{
code: "ab",
name: "ABKHAZIAN"
},
{
code: "aa",
name: "AFAR"
},
{
code: "af",
name: "AFRIKAANS"
}
...
]
Returns information about your account and it's status.
detectLanguage.status(function(error, result) {
console.log(JSON.stringify(result));
});
{
date: "2015-02-21",
requests: 31,
bytes: 429,
plan: "FREE",
plan_expires: null,
daily_requests_limit: 5000,
daily_bytes_limit: 1048576,
status: "ACTIVE"
}
Peter Andreas Moelgaard (GitHub, Twitter)
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0