npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

en-zh-translator

v1.0.0

Published

英汉双语翻译命令行工具

Readme

// README.md

en-zh-translator

一个简单易用的英汉双语翻译命令行工具,支持中英文自动检测和互译。

安装

# 全局安装
npm install -g en-zh-translator

# 或者通过 npx 使用
npx en-zh-translator "你好世界"

特点

  • 🌐 支持中英文双向翻译
  • 🔍 自动检测输入文本的语言
  • 📋 支持从剪贴板读取文本
  • 📝 支持将翻译结果复制到剪贴板
  • 🔊 可显示发音参考(如有)
  • 🎨 美观的命令行界面

使用方法

基本用法:

# 使用命令 translate 或简写 trans 或 en-zh
translate "Hello world"   # 英译中
translate "你好世界"      # 中译英

命令选项

选项:
  -f, --from       源语言 [选项: "auto", "en", "zh"] [默认: "auto"]
  -t, --to         目标语言 [选项: "en", "zh"] [默认: "auto"]
  -c, --clipboard  翻译剪贴板内容 [布尔]
  -p, --pronunciation  显示发音 [布尔] [默认: true]
  --copy           复制结果到剪贴板 [布尔] [默认: false]
  -v, --version    显示版本号 [布尔]
  -h, --help       显示帮助信息 [布尔]

示例

# 自动检测语言并翻译
translate "Hello world"

# 指定从英文翻译为中文
translate -f en -t zh "Hello world"

# 翻译剪贴板中的内容
translate -c

# 翻译并复制结果到剪贴板
translate --copy "Hello world"

# 翻译但不显示发音
translate -p false "Hello world"

配置

默认情况下,该工具使用免费的 MyMemory 翻译 API。如果您需要使用 Google Translate API,请设置环境变量:

# 在 Linux/Mac 中
export GOOGLE_TRANSLATE_API_KEY=your_api_key_here

# 在 Windows 中
set GOOGLE_TRANSLATE_API_KEY=your_api_key_here

然后修改 src/config.js 中的 DEFAULT_API'google'

高级用法

通过管道使用

echo "Hello world" | translate
cat file.txt | translate

与其他命令组合使用

# 翻译并在浏览器中朗读
translate "Hello world" | say

# 翻译文本文件内容
translate "$(cat text.txt)"

许可证

MIT