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

scancscode

v1.0.58

Published

C# 代码字符串提取与国际化处理工具集。

Readme

scancscode

C# 代码字符串提取与国际化处理工具集。

功能简介

scancscode 是一个用于处理 C# 代码国际化的命令行工具集,主要功能包括:

  • 扫描代码字符串:从 C# 代码中自动提取需要国际化的字符串字面量, 生成 CSV 文件
  • CSV 文件处理:合并、精简 CSV 语言文件
  • 自动翻译:调用翻译 API 批量翻译 CSV 文件中的内容

安装

# 克隆项目
git clone <repository-url>
cd scancscode

# 安装依赖
npm install

# 构建项目
npm run build

命令行工具

1. scanliterals - 扫描代码字符串

扫描 C# 代码中的字符串字面量,并输出到 CSV 文件。

npx scanliterals --cscodedir <目录> --configdir <目录> --outcsv <文件> --langs <语言>

参数说明

| 参数 | 说明 | | ------------- | --------------- | | --cscodedir | C# 代码目录,支持多个目录 | | --configdir | 配置文件目录,支持多个目录 | | --outcsv | 输出 CSV 文件路径 | | --langs | 语言列表(默认 zh_cn) | | --verbose | 显示详细日志 |

示例

npx scanliterals \
  --cscodedir ./GameClient/Assets/Bundles/FGUI/ \
  --configdir ./GameClient/Assets/Bundles/GameConfigs/ \
  --outcsv ./output/Translation.csv \
  --langs zh_cn

2. slimlangs - 精简 CSV 文件列

将多个 CSV 文件合并,并按指定语言列表精简列。

npx slimlangs --incsv <文件> --outcsv <文件> --langs <语言>

参数说明

| 参数 | 说明 | | ---------- | ------------------ | | --incsv | 输入 CSV 文件路径,支持多个文件 | | --outcsv | 输出 CSV 文件路径 | | --langs | 要保留的语言列表 |

示例

npx slimlangs \
  --incsv ./Auto.csv ./Manual.csv \
  --outcsv ./ScriptTrans.csv \
  --langs zh_cn

3. transcsv - 翻译 CSV 文件

使用翻译 API 将 CSV 文件中的内容从源语言翻译到目标语言。

npx transcsv --incsv <文件> --outcsv <文件> --fromLang <语言> --toLangs <语言> --apiKey <密钥> --appId <应用ID>

参数说明

| 参数 | 说明 | | ------------ | ------------- | | --incsv | 输入 CSV 文件路径 | | --outcsv | 输出 CSV 文件路径 | | --fromLang | 源语言(如 zh_cn) | | --toLangs | 目标语言列表 | | --apiKey | 翻译 API 密钥 | | --appId | 翻译 API 应用 ID |

示例

npx transcsv \
  --incsv ./ScriptTrans.csv \
  --outcsv ./ScriptTrans_translated.csv \
  --fromLang zh_cn \
  --toLangs zh_hk en_us \
  --apiKey your_api_key \
  --appId your_app_id

核心模块

CSharpStringExtractor

C# 代码字符串提取器,支持多种字符串格式:

  • 普通字符串:"Hello World"
  • 插值字符串:$"Hello {name}"
  • 原生插值字符串:$@"Hello {name}"
  • string.Format 调用:string.Format("Hello {0}", name)
  • Tr.Format 调用:Tr.Format("Hello {0}", name)
  • .text/.title 赋值:label.text = "Hello"
  • 三元表达式:condition ? "Yes" : "No"
  • 字符串拼接:"Hello " + name
  • switch case:case "value":

CsvAutoTranslator

CSV 文件自动翻译器,基于百度翻译 API 实现批量翻译功能。

CSVUtils

CSV 文件处理工具集,提供 CSV 文件的读取、写入、合并和精简功能。

工作流示例

完整国际化处理流程

# 步骤 1: 扫描代码中的字符串字面量
npx scanliterals \
  --cscodedir ./GameClient/Assets/Bundles/FGUI/ \
  --configdir ./GameClient/Assets/Bundles/GameConfigs/ \
  --outcsv ./Translation/Auto.csv \
  --langs zh_cn

# 步骤 2: 合并并精简 CSV(可选)
npx slimlangs \
  --incsv ./Translation/Auto.csv ./Translation/Manual.csv \
  --outcsv ./Translation/ScriptTrans.csv \
  --langs zh_cn

# 步骤 3: 翻译到目标语言
npx transcsv \
  --incsv ./Translation/ScriptTrans.csv \
  --outcsv ./Translation/ScriptTrans.csv \
  --fromLang zh_cn \
  --toLangs zh_hk \
  --apiKey your_api_key \
  --appId your_app_id

开发

运行测试

npm test

构建项目

npm run build

语言代码参考

| 语言 | 代码 | | -------- | ------ | | 简体中文 | zh_cn | | 繁体中文(香港) | zh_hk | | 繁体中文(台湾) | zh_tw | | 英语 | en_us | | 日语 | ja_jp | | 韩语 | ko_kr |

许可证

ISC