vve-baidu-translate-service
TypeScript icon, indicating that this package has built-in type declarations

3.0.2 • Public • Published

baidu-translate-service

该库通过封装了百度翻译的API信息,支持浏览器,客户端,nodejs调用百度翻译接口,欢迎大家使用,记得start

parameter

字段名 类型 是否必填 描述 备注
q string 请求翻译query UTF-8编码
to string 翻译目标语言 不可设置为auto
appid string APPID 可在管理控制台查看
key string 秘钥 在控制台申请查看
from string 翻译源语言 默认值为auto
tts integer 是否显示语音合成资源 0-显示,1-不显示,默认值为 1
dict integer 是否显示词典资源 0-显示,1-不显示 ,默认值为 1
action integer 判断是否需要使用自定义术语干预API 1-是,0-否,默认值为 0

Response

参考官方文档链接

Demo

Browsers (接口请求存在跨域问题)

<script src="https://unpkg.com/vve-baidu-translate-service/lib/baiduTranslateService.js"></script>

<script>
  baiduTranslateService({
    appid: "",
    key: "",
    to: "en",
    q: "今天星期几?",
  }).then((result) => {
    console.log(result);
  });
</script>

Nodejs

npm install vve-baidu-translate-service
const baiduTranslateService = require("vve-baidu-translate-service").default;

baiduTranslateService({
  appid: "",
  key: "",
  to: "en",
  q: "今天星期几?",
}).then((result) => {
  console.log(result);
});

Package Sidebar

Install

npm i vve-baidu-translate-service

Weekly Downloads

25

Version

3.0.2

License

MIT

Unpacked Size

28.9 kB

Total Files

6

Last publish

Collaborators

  • nianqin