0.4.3 • Published 5 years ago
baidu-translate-api v0.4.3
baidu-translate-api 
A free and unlimited API for Baidu Translate
Translations
Install
npm install --save baidu-translate-api or
yarn add baidu-translate-apiUsage
const translate = require("baidu-translate-api");
translate("让我们来翻译吧!").then(res => {
console.log(res.trans_result.dst);
// Let's translate it!
});API
translate(query, options)
query
Type: String
The text to be translated
options
Type: Object
from
Type:
StringDefault:autoThe language in which the query text or
auto. Contain in Languagesto
Type:
StringDefault:enThe language in which the text should be translated. Contain in Languages
requestOpts
Type:
RequestOptionsDefault:{}reference request options
Returns an object:
from- The lanuage in which the query text.totrans_result(object)dst- The translationsrc- The source (equal to query)
setGlobalConfig(config)
| name | desc |
|---|---|
| useLocalStore | store the token config in memory. default: false. |
Languages
| abbr | name |
|---|---|
| auto | Automatic detection |
| zh | Chinese |
| en | English |
| yue | Cantonese |
| wyw | Classical Chinese |
| jp | Japanese |
| kor | Korean |
| fra | French |
| spa | Spanish |
| th | Thai |
| ara | Arabic |
| ru | Russian |
| pt | Portuguese |
| de | German |
| it | Italian |
| el | Greek language |
| nl | Dutch |
| pl | Polish |
| bul | Bulgarian |
| est | Estonian |
| dan | Danish |
| fin | Finnish |
| cs | Czech |
| rom | Romanian |
| slo | Slovenia |
| swe | Swedish |
| hu | Hungarian |
| cht | Traditional Chinese |
| vie | Vietnamese |
AFTERWORD
If this repo helped you, give me a star and it's the greatest encouragement to me.