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

i18n-alltranslate

v1.2.5

Published

Generate i18N language files

Readme

i18n-alltranslate

说明

重磅更新:支持 OpenAI 翻译!支持自定义 api_key、base_url、model
支持 JSON 文件格式的语言包内容翻译成指定语种并写入其他语言 JSON 文件
目前支持 有道云翻译 、阿里翻译、谷歌翻译、OpenAI 翻译
ps:翻译接口有请求频率限制,若一次翻译不成功,建议多试几次呦,或者更换 ip 绕过限制。

阿里翻译说明:
除繁体中文、蒙语、粤语外,其他212种语言,可支持任意两种语言之间互译。
繁体中文、蒙语、粤语仅支持与中文之间的互译。

安装

npm install --save-dev i18n-alltranslate
// or
yarn add i18n-alltranslate

调用方法

建立一个 js 文件,写入以下内容

const { i18nI18nLang, i18nI18nTranslate } = require('i18n-alltranslate')
const { YDConfigSet, ALIConfigSet, GConfigSet, openAIConfigSet, setI18nLang, setI18nTranslate } = require('i18n-alltranslate')

/**
 * @description: 将中文 JSON 文件翻译写入其他语言 JSON 文件
 * @param {String} dir/语言文件目录
 * @param {String} zh/中文语言文件路径
 * @param {String} other/其他语言文件路径
 * @param {String} lang/语言种类,默认英文
 * @param {String} type/翻译类型,默认全部翻译 all/翻译全部内容 new/仅翻译新增内容
 * @return {type}
 */
const translate = async (dir, zh, en, fromLang, toLang, type) => {
  // 使用 YDConfigSet 方法传入有道云翻译key,则使用有道云翻译
  // YDConfigSet({ YD_APPKEY: '', YD_KEY: '' })
  // 使用 ALIConfigSet 方法传入阿里翻译key,则使用阿里翻译
  // ALIConfigSet({ accessKeyId: '', accessKeySecret: '' })
  // 使用 GConfigSet 方法传入谷歌翻译key和代理信息,则使用谷歌翻译
  // GConfigSet(G_KEY, { proxy: { host: '127.0.0.1', port: '7890' } })
  // 使用 openAIConfigSet,设置 api_key、base_url、model,使用 支持 OpenAI 的 ai 翻译
  openAIConfigSet({
    OPENAI_API_KEY: '',
    OPENAI_BASE_URL: '',
    OPENAI_MODEL: ''
  })
  await setI18nLang(dir, zh)
  await setI18nTranslate(zh, en, fromLang, toLang, type)
}
translate('demo', 'demo/zh.json', 'demo/en.json', 'zh', 'en', 'all')