Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
yandex-translator
Advanced tools
A promise based implementation of Yandex Translate API for Node.js.
yandex-translator is a a promise based implementation of Yandex Translate API for node.js
To start using Yandex Translate API we need to get an API key first, which we will get it from the API key request form after having created an account the registration page.
npm install yandex-translator --save
Import the yandex-translator package with with the API key obtained from the API key request form.
const yandexTranslator = require('yandex-translator')(apiKey);
Get the languages that yandex-translator support their translation:
yandexTranslator.getAvailableLanguages().then(
(result) => {
console.log(result);
},
(error) => {
console.log(error);
}
);
The parameters parameter is an object which can contain any of the following attributes:
Attribute | Type | Description | Default value |
---|---|---|---|
[ui] | string | The returned language names are output in the language corresponding to the code in this parameter. The supported language codes are shown in the list of supported languages. | |
[resultFormat] | string | The result format which can be either JSON or XML. | JSON |
[apiKey] | string | Another API key to run only this request with | The same value as the initialized API key. |
Detect a text language:
yandexTranslator.detectLanguage({text: 'Bonjour'}).then(
(result) => {
console.log(result);
},
(error) => {
console.log(error);
}
);
The parameters parameter is an object which can contain any of the following attributes:
Attribute | Type | Description | Default value |
---|---|---|---|
text* | string | The text that we want to detect it's language. | |
[hints] | array | An array of the most likely languages (they will be given preference when detecting the text language). | [] |
[resultFormat] | string | The result format which can be either JSON or XML. | JSON |
[apiKey] | string | Another API key to run only this request with | The same value as the initialized API key. |
Translate a text:
yandexTranslator.translate({text: 'Bonjour', to: 'en'}).then(
(result) => {
console.log(result);
},
(error) => {
console.log(error);
}
);
The parameters parameter is an object which can contain any of the following attributes:
Attribute | Type | Description | Default value |
---|---|---|---|
text* | string | The text that we want to detect it's language. | |
to* | string | The language which the text will be translated to. | |
[from] | string | The source language of the text. If it's then the service will try to detect the source language automatically. | |
[options] | integer | Whether the response should include the automatically detected language of the text being translated: 1 to include the automatically detected language of the text, 0 to not | 1 |
[format] | string | The text format which can be plain (Text without markup) or html (Text in HTML format). | plain |
[hints] | array | An array of the most likely languages (they will be given preference when detecting the text language). | [] |
[resultFormat] | string | The result format which can be either JSON or XML. | JSON |
[apiKey] | string | Another API key to run only this request with | The same value as the initialized API key. |
MIT.
FAQs
A promise based implementation of Yandex Translate API for Node.js.
We found that yandex-translator 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.