🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis
Socket
Book a DemoInstallSign in
Socket

@aplus-frontend/translate-utils

Package Overview
Dependencies
Maintainers
9
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aplus-frontend/translate-utils

翻译工具函数,支持有道,谷歌

latest
npmnpm
Version
1.0.0
Version published
Maintainers
9
Created
Source

@aplus-frontend/translate-utils

一个翻译工具函数库。支持有道,谷歌,百度。

install

pnpm i @aplus-frontend/translate-utils

api

googleTranslate

interface GoogleOption {
  word: string // 待翻译文本
  originLang: string // 源语言
  targetLang: string // 目标语言
  proxy: string | undefined // 代理地址
}

declare function googleTranslate(option: GoogleOption): Promise<string>

例子

const res = await googleTranslate({
  word: '翻译内容',
  originLang: 'zh-CN',
  targetLang: 'en-US',
  proxy: 'socks://127.0.0.1:1080',
})

youdaoTranslate

interface YoudaoConfig {
  key?: string // 有道词典appKey
  secret?: string // 有道词典appSecret
}

interface YoudaoOption {
  word: string // 待翻译文本
  originLang: string // 源语言
  targetLang: string // 目标语言
  option: YoudaoConfig // 有道词典配置
}

declare function youdaoTranslate(option: YoudaoOption): Promise<string>

例子

const res = await youdaoTranslate({
  word: '翻译内容',
  originLang: 'zh-CN',
  targetLang: 'en-US',
  option: {
    key: '2d8e89a6fd072117',
    secret: 'HiX7rGmYRad3ISMLYexRLfpkJi2taMPh',
  },
})

baiduTranslate

interface BaiduConfig {
  key?: string
  secret?: string
}

interface BaiduOption {
  word: string // 待翻译文本
  originLang: string // 源语言
  targetLang: string // 目标语言
  option: BaiduConfig // 有道词典配置
}

declare function baiduTranslate(option: YoudaoOption): Promise<string>

例子

const res = await baiduTranslate({
  word: '翻译内容',
  originLang: 'zh-CN',
  targetLang: 'en-US',
  option: {
    key: '2d8e89a6fd072117',
    secret: 'HiX7rGmYRad3ISMLYexRLfpkJi2taMPh',
  },
})

Keywords

@aplus-frontend

FAQs

Package last updated on 31 May 2024

Did you know?

Socket

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.

Install

Related posts