Translate Platforms
A Node module to translate words by multiple platforms.
Installation
npm install translate-platforms
Usage
const { google, microsoft, youdao, baidu } = require('translate-platforms');
const result = await google('Hello world', { to: google.ja });
console.log(result);
microsoft('こんにちは世界', { to: microsoft.zh }).then(result => {
console.log(result);
});
Parameters
function translate(word: string, language: { from: string, to: string }): object
parameter | description |
---|
word | The word want to translate. |
from | The source language. Default is recognized automatically(auto ). (Optional) |
to | The target language. Default is Chinese(zh ). (Optional) |
Return Object
key | description |
---|
lang | The source language and target language. |
word | The word want to translate. |
text | The most match result. |
candidate | Other translate result. |
Language Code
Each platform supports different translation languages. You can check the interface function properties.
Support Platform
Supported platforms are Google, Microsoft, Yandex, Baidu, Tencent and Youdao.
Notice
Tencent does not support mutual translation of all languages, you can use the support
function to get the translation language supported by the language.