
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
mute-english-api
Advanced tools
🚀 一个功能丰富的npm包,提供英语词典查询和百度翻译等API服务,支持多种翻译服务集成。
npm install mute-english-api
import { fetchTranslation, getWordMeaning } from 'mute-english-api';
// 基础词典查询
const data = await fetchTranslation('hello');
console.log(data);
// 获取详细释义
const meaning = await getWordMeaning('world');
if (meaning.success) {
console.log(`${meaning.word}: ${meaning.meanings[0]?.definitions[0]?.definition}`);
}
import { setBaiduTranslateConfig, translateText, quickTranslate } from 'mute-english-api';
// 方式1: 设置配置后使用
setBaiduTranslateConfig('your_appid', 'your_key');
const result = await translateText('Hello World', 'en', 'zh');
console.log(result.translated); // 输出:你好世界
// 方式2: 一键翻译(推荐简单场景)
const quickResult = await quickTranslate('your_appid', 'your_key', 'Good morning!');
console.log(quickResult.translated); // 输出:早上好!
fetchTranslation(word)
获取英语单词的完整词典数据。
参数:
word
(string) - 要查询的英语单词返回: Promise<Array>
- 词典数据数组
getWordMeaning(word)
获取单词的结构化释义信息。
返回格式:
{
success: boolean,
word: string,
phonetics: Array,
meanings: Array,
sourceUrls: Array
}
getWordPhonetics(word)
获取单词的发音信息。
setBaiduTranslateConfig(appid, key)
设置百度翻译API配置。
参数:
appid
(string) - 百度翻译API的APPIDkey
(string) - 百度翻译API的KEYtranslateText(text, from, to)
翻译文本。
参数:
text
(string) - 需要翻译的文本from
(string) - 源语言代码,默认'en'to
(string) - 目标语言代码,默认'zh'返回格式:
{
success: boolean,
translated: string,
data: Object,
error?: string
}
batchTranslate(texts, from, to, delay)
批量翻译文本数组。
参数:
texts
(Array) - 文本数组from
(string) - 源语言,默认'en'to
(string) - 目标语言,默认'zh'delay
(number) - 请求间隔(毫秒),默认1000detectLanguage(text)
检测文本语言。
getSupportedLanguages()
获取支持的语言列表。
quickTranslate(appid, key, text, from, to)
一键设置配置并翻译。
export BAIDU_TRANSLATE_APPID=your_appid
export BAIDU_TRANSLATE_KEY=your_key
设置环境变量后,无需调用 setBaiduTranslateConfig()
。
import { configManager } from 'mute-english-api';
// 设置百度翻译配置
configManager.setBaiduTranslateConfig('appid', 'key');
// 自定义服务配置
configManager.setConfig('myService', {
apiUrl: 'https://api.example.com',
apiKey: 'my_key'
});
// 获取配置
const config = configManager.getConfig('myService');
百度翻译支持以下语言:
代码 | 语言 | 代码 | 语言 |
---|---|---|---|
auto | 自动检测 | zh | 中文 |
en | 英语 | jp | 日语 |
kor | 韩语 | spa | 西班牙语 |
fra | 法语 | de | 德语 |
ru | 俄语 | it | 意大利语 |
pt | 葡萄牙语 | ara | 阿拉伯语 |
mute-english-api/
├── index.js # 主入口文件
├── src/
│ ├── config/
│ │ └── index.js # 配置管理器
│ ├── services/
│ │ ├── baiduTranslate.js # 百度翻译服务
│ │ └── dictionaryApi.js # 英语词典服务
│ └── utils/
│ └── crypto.js # 加密工具
├── examples/
│ └── usage.js # 使用示例
├── test/
│ └── index.test.js # 测试文件
└── package.json
// 导入特定服务
import { baiduTranslateService } from 'mute-english-api/baidu-translate';
import { dictionaryService } from 'mute-english-api/dictionary';
import configManager from 'mute-english-api/config';
import { configManager } from 'mute-english-api';
// 添加Google翻译配置
configManager.setConfig('googleTranslate', {
apiKey: 'your_google_api_key',
apiUrl: 'https://translation.googleapis.com/language/translate/v2'
});
# 克隆项目
git clone https://github.com/czm233/mute-english-api.git
cd mute-english-api
# 安装依赖
npm install
# 运行示例(需要先设置百度API密钥)
node examples/usage.js
ISC License
欢迎提交Issue和Pull Request!
FAQs
提供英语词典和百度翻译等API服务的npm包,支持多种翻译服务集成
We found that mute-english-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.