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 🙏

© 2024 – Pkg Stats / Ryan Hefner

i18n-ai-trans

v1.1.3

Published

i18n-translate 是一个高效、简介的多语言翻译工具,安装后只需简单几步就能实现整个多语言文本的快速翻译。

Downloads

65

Readme

i18n-ai-trans

i18n-ai-trans i18n-ai-trans 是一个高效、简洁的多语言翻译工具,开箱即用,零依赖,安装后只需简单几步就能实现整个多语言文本的快速翻译。

功能演示

特点

  • 简单易用: 开箱即用,零依赖,仅需简单的配置与命令即可启动翻译流程。
  • 高效快速: 通过AI进行翻译,只需要短短几秒就能完成整个多语言的翻译工作。
  • 增量翻译: 翻译前进行内容检查,对于已翻译过或者修改过的字段不会翻译。
  • 高度可定制: 支持通过配置文件扩展功能(主要是优化prompt)。
  • 支持namespace: 支持命名空间(项目较大时会将某个语言的翻译文本放在文件夹中,插件在翻译前会自动检测是否启用了命名空间,再进行翻译工作)。

快速开始

安装

npm install i18n-ai-trans --save-dev

初始化配置

npx i18n-ai-trans init

这将创建一个默认的配置文件 i18n_translate.config.js

配置文件

编辑 i18n_translate.config.js 来定义您的翻译设置,例如:

module.exports = {
    // 豆包创建的api_key
    API_KEY: "",
    // 创建的模型ID
    ENDPOINT_ID: "",
    // 模型预设内容
    SystemContent: `
        #角色
        假如你是多语言翻译专家,你将根据客户的翻译需求,根据以下规则一步步执行任务。    
        #背景补充    
        connect app是一个同步连接器项目。主要功能是同步shopify和TikTok这两个电商平台的产品和订单
        
        #任务描述与要求    
        1. 仔细分析客户提供的 connect app 的 Json 源文本(英语)和语言简码(json原文本和语言简码用空格隔开)。   
        2. 将源文本中所有 value 字段准确无误地翻译为语言简码对应的语言文本(例如:zh简码翻译为中文)。        
        3. 确保翻译的准确性和流畅性,符合翻译语言的表达习惯。    
        4. 对于一些专业术语或特定语境下的词汇,要进行恰当的翻译,不能出现歧义。   
        5.  严格按照参考实例的格式输入与输出
        #参考示例    
        示例 1:    
        输入:{"live":"Live"} zh
        输出:{"live":"活跃的"}    
        示例 2:    
        输出:{"order_id":"12345","description":"A beautiful dress"} zh
        输出:{"order_id":"12345","description":"一件漂亮的连衣裙"}
    `,
    // 翻译目录(相对路径)
    translateDir: "",
    // 源语言,默认en
    sourceLang: "en",
    // app需要支持多少种语言
    langs: ["en", "zh"]
}

| 配置字段 | 含义 | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------- | | API_KEY | 火山方舟模型的API_KEY | | ENDPOINT_ID | 模型的接入点ID | | SystemContent | 预制文本,设定模型的行为和背景,告知模型需要扮演的角色。可以查看Prompt最佳实践了解更多 | | translateDir | 需要翻译的文件夹目录(相对路径) | | sourceLang? | 源语言 默认:en | | langs? | app需要支持哪些语言,例如:["en", "zh-CN"] |

开始翻译

npx i18n-ai-trans translate

此命令会自动处理未翻译的条目,并更新相应的语言包文件。

工作原理

  1. 检测缺失翻译: 找出语言包中的缺失或者未翻译的字段。
  2. 调用 AI 接口: 调取AI翻译接口进行文本翻译。
  3. 更新语言包: 将新翻译的内容整合到对应的语言包中。

后期TODO

  • [ ] 目前只支持字节的火山方舟大模型,有需要的话还会接入其他AI。
    • [ ] chatGPT
    • [ ] 阿里通义