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 🙏

© 2025 – Pkg Stats / Ryan Hefner

intl-csv2json

v1.0.4

Published

A tool for converting CSV format translation files to JSON format

Downloads

12

Readme

intl-csv2json

npm version License: MIT

一个将 CSV 格式的多语言文件转换为 JSON 格式的命令行工具。

中文 | English

安装

npm install -g intl-csv2json

使用方法

基本用法

intl-csv2json --input <CSV文件路径> --template <模板JSON文件路径>

或者使用简写形式:

intl-csv2json -i <CSV文件路径> -t <模板JSON文件路径>

交互式命令

你也可以使用交互式命令来运行工具:

# 这将启动一个交互式界面,引导你输入所需的参数
intl-csv2json

参数说明

  • --input, -i: CSV 文件路径(必需)
  • --template, -t: 模板 JSON 文件路径(必需)
  • --output, -o: 输出目录(可选,默认为当前目录)
  • --lang-codes, -l: 语言代码列表,用逗号分隔, 按照 CSV 文件中的语言列顺序填写(可选,默认为 'zh,en')
  • --group, -g: 要处理的 JSON 分组 (可选,默认为空)
  • --trim: 是否对值进行 trim 处理(可选,默认为 false)
  • --lang: 显示语言(可选,'zh'或'en',默认为自动检测)
  • --use-template-default, -d: 无翻译时是否使用模板值作为默认值(可选,默认为 false)

示例

intl-csv2json -i "./language_translations.csv" -t "./zh.json" -o "./" -l "zh,en,ar"

# 使用模板值作为缺失翻译的默认值
intl-csv2json -i "./language_translations.csv" -t "./zh.json" -d

CSV 文件格式

CSV 文件的第一行应包含语言名称,从第二行开始包含翻译内容。第一列为 JSON 模版对应的源语言值,后续列为对应的其他语言翻译。

示例: | 中文 | 英语 | 阿拉伯语 | | ---- | ---- | -------- | | {{num}}金币 | {{num}} Coins | {{num}} عملات | | 奖励 | Reward | مكافأة | | {{num}}倍收益,{{goldNum}}金币 | {{num}}x earnings, {{goldNum}} coins | {{num}}× {{goldNum}} عملات | | {{num}}人 | {{num}} People | {{num}} شخصًا | | 获胜排行 | Winning Rank | ترتيب الفائزين |

模板 JSON 文件格式

{
  "price": "{{num}}金币",
  "reward": "奖励",
  "earnings": "{{num}}倍收益,{{goldNum}}金币",
  "winningRank": "获胜排行",
  "common": {
    "people": "{{num}}人"
  }
}

输出

工具会在指定的输出目录中生成对应语言的 JSON 文件,例如 en.jsonar.json 等。

en.json

{
  "price": "{{num}} Coins",
  "reward": "Reward",
  "earnings": "{{num}}x earnings, {{goldNum}} coins",
  "winningRank": "Winning Rank",
  "common": {
    "people": "{{num}} People"
  }
}

ar.json

{
  "price": "{{num}} عملات",
  "reward": "مكافأة",
  "earnings": "{{num}}× {{goldNum}} عملات",
  "winningRank": "ترتيب الفائزين",
  "common": {
    "people": "{{num}} شخصًا"
  }
}

许可证

MIT