Package Exports
- @ifreeovo/translate-utils
- @ifreeovo/translate-utils/dist/cjs/index.js
- @ifreeovo/translate-utils/dist/esm/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ifreeovo/translate-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@ifreeovo/translate-utils
一个翻译工具函数库。支持有道,谷歌。
install
npm i @ifreeovo/translate-utilsapi
googleTranslate
declare function googleTranslate(
word: string, // 待翻译文本
originLang: string, // 源语言
targetLang: string, // 目标语言
proxy: string | undefined // 代理地址
): Promise<string>例子
const res = await googleTranslate('翻译内容', 'zh-CN', 'en-US', 'socks://127.0.0.1:1080')youdaoTranslate
interface YoudaoConfig {
key?: string // 有道词典appKey
secret?: string // 有道词典appSecret
}
declare function youdaoTranslate(
word: string, // 待翻译文本
originLang: string, // 源语言
targetLang: string, // 目标语言
option: YoudaoConfig // 有道词典配置
): Promise<string>例子
const res = await googleTranslate('翻译内容', 'zh-CN', 'en-US', {
key: '2d8e89a6fd072117',
secret: 'HiX7rGmYRad3ISMLYexRLfpkJi2taMPh',
})