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

lang-sync-cli

v0.8.7

Published

An automated tool for extracting, translating and replacing multilingual text in frontend projects.

Readme

lang-sync-cli

npm GitHub license

功能简介

lang-sync-cli 是一个前端多语言自动化工具,专为现代化前端项目国际化改造而设计。它通过中文词条提取、在线协作翻译、智能代码替换和后期维护检查,大幅降低多语言开发成本,提升团队协作效率。

核心特性

  • 中文词条提取 - 自动扫描项目文件,精准提取中文文本和符号
  • 在线协作翻译 - 无缝对接飞书在线文档,支持多人实时协作
  • 智能代码替换 - 自动将中文替换为国际化函数调用,并补全相关依赖
  • 翻译完整性检查 - 确保项目中没有遗漏的未翻译文本

安装

npm install -g lang-sync-cli
# 或
yarn global add lang-sync-cli
# 或
pnpm add -g lang-sync-cli

快速开始

1. 初始化配置

zklang init

首次使用时运行此命令,引导式配置飞书应用和文档等基本信息。

2. 扫描提取中文词条

zklang scan
# 或完整命令:zklang syncZhToOnlineDoc

zklang scan <sheetName>
# 可指定扫描后要上传的表格名, 若缺省默认从配置取

zklang scan -k <prefix.>
# 可指定上传的表格里sheet页中列key的前缀, 若缺省默认从配置取

扫描项目中的所有 Vue/JS/TS 文件,提取中文文本并自动写入飞书在线表格,方便翻译团队协作。

3. 拉取翻译数据并生成语言文件

zklang pull
# 或完整命令:zklang pullExcelGenerateLangFile

zklang pull <sheetName>
# 可指定要拉取数据的目标表格名, 若缺省默认从配置取

从飞书在线表格拉取已翻译的多语言数据,自动生成本地语言文件(如 zh-CN.json, en.json 等)。

4. 智能替换代码中的中文文本

zklang replace
# 或完整命令:zklang replaceFilesByLangData

自动将项目中的中文文本替换为 t('key') 函数调用,补全相关依赖并处理代码格式,保持代码整洁。

5. 检查翻译完整性

zklang check
# 或完整命令:zklang translationCheck

扫描项目,检测是否有遗漏的未翻译文本,确保多语言覆盖完整。

6. 查看帮助

zklang help

查看所有可用命令的详细说明。

使用场景

1. 大型项目(老项目)从零接入多语言

# 1. 初始化配置
zklang init

# 2. 扫描现有中文词条到飞书文档
zklang scan

# 3. 等待翻译团队完成翻译后拉取数据
zklang pull

# 4. 自动替换代码中的中文
zklang replace

# 5. 检查是否有遗漏
zklang check

2. 已有国际化项目维护

# 1. 扫描新增的中文词条
zklang scan

# 2. 拉取最新的翻译数据
zklang pull

# 3. 替换新增的中文文本
zklang replace

3. 翻译完成后更新

# 翻译人员在飞书表格里填充和完善翻译信息之后
zklang pull

飞书和翻译集成

  • 1.创建飞书电子表格作为翻译协作平台,并开通相关权限
  • 2.表格在数据上传后会自动生成以下列:key, 中文简体(zh-CN), 英语(en)
  • 3.通过 zklang init 配置飞书 ID/秘钥 、工作表和翻译账号(如需翻译)等信息

项目结构

your-project/
├── src/
│   ├── lang/
│   │   ├── zh-CN.json    # 自动生成的中文简体语言文件
│   │   ├── en.json       # 自动生成的英语语言文件
│   │   ├── ...json       # 自动生成的其他语言文件
│   │   └── index.js    # 语言文件导出
└── package.json

常见问题

Q: 支持哪些前端框架?

A: 支持 Vue 2/3,使用 Webpack 或 Vite 构建的 JavaScript/TypeScript 的项目。

Q: 是否会替换注释和 console 里的中文文本?

A: 不会。在扫描提取,替换等环节都会忽略掉单行注释、多行注释、HTML 注释、console 里的中文汉字和符号。

Q: 飞书文档是必须的吗?

A: 是的,目前主要支持飞书在线表格作为翻译协作平台。

Q: 是否支持多语种的自动翻译?

A: 是的,可以通过配置使用百度翻译或 Bing 翻译进行多语种自动翻译,也支持纯人工翻译模式。

Q: 现在已经有强大的 AI 工具 (Cursor/Claude Code), 还需要这个自动化工具吗?

A: 确实,AI 工具在在代码理解和生成方面非常强大。然而,对于老项目从零开始的国际化改造这类系统化工程:使用 AI 工具需多次沟通调整提示词、翻译和文档协作需要找到对应的 MCP 进行对接、输出结果可能存在不一致 性、批量生成后需要更多的人工复查和修复、每个项目都需要重新沟通和调整、难以确保团队产出一致等缺点。相比之下,lang-sync-cli作为专用工具在效率、一致性、集成度和易用性方面有明显优势。此外 ,lang-sync-cli 与 AI 工具比也有改造耗时更少(大项目几分钟完成改造)、不收集上传代码更安全、零成本不付费上班等独特优势。

优化建议

有任何问题或建议,请点击这里 Issue Report

许可证

MIT © 2025-present flyfox
完整协议见 MIT 文件