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

create-tinyi18n

v1.1.0

Published

基于配置文件快速生成项目本地化所需的 messages 文件

Readme

create-tinyi18n

npm version License: MIT Node.js Version

基于配置文件快速生成项目本地化所需的 messages 文件的 CLI 工具。

特性

  • 🚀 基于配置文件驱动,无需交互
  • 📁 支持多目录、多命名空间批量生成
  • 🎯 简单易用,专注于文件生成
  • 🔧 支持自定义配置文件路径
  • ✨ 美观的命令行输出和进度提示

安装

推荐方式(无需安装)

# 使用 pnpm(推荐)
pnpm create tinyi18n@latest

# 使用 npx
npx create-tinyi18n@latest

全局安装

npm install -g create-tinyi18n@latest
# 或者
pnpm add -g create-tinyi18n@latest

使用方法

1. 创建配置文件

在项目根目录创建 tinyi18n.config.json 配置文件:

💡 提示:可以参考 tinyi18n.config.json 查看完整的配置示例

{
  "url": "https://v1.tinyi18n.com",
  "secret": "your-secret-key",
  "clean": false,
  "entries": [
    {
      "dir": "./src/locales",
      "flat": false,
      "clean": true,
      "namespaces": ["sso", "shared"]
    },
    {
      "dir": "./src/other-locales",
      "flat": false,
      "namespaces": ["admin", "dashboard"]
    }
  ]
}

2. 运行命令

# 使用默认配置文件 tinyi18n.config.json
create-tinyi18n

# 指定自定义配置文件
create-tinyi18n --config ./config/my-config.json

配置文件说明

| 字段 | 类型 | 必需 | 说明 | |------|------|------|------| | url | string | 否 | 远程服务地址(预留字段) | | secret | string | 否 | 鉴权密钥(预留字段) | | clean | boolean | 否 | 是否在生成前清理目录中的现有文件,默认 false | | entries | array | 是 | 生成任务配置数组 | | entries[].dir | string | 是 | 输出目录路径 | | entries[].flat | boolean | 否 | 是否为扁平结构,默认 false | | entries[].clean | boolean | 否 | 是否在生成前清理该目录中的现有文件,未设置时继承顶层配置 | | entries[].namespaces | array | 是 | 命名空间列表 |

clean 参数说明

clean 参数用于控制是否在生成新文件前清理目标目录中的现有文件:

  • 顶层配置:设置全局默认的清理行为
  • Entry级配置:为特定目录单独设置清理行为
  • 继承机制:如果 entry 中未设置 clean,则继承顶层的 clean 配置

使用场景:

  • clean: true - 适用于需要完全重新生成的目录
  • clean: false - 适用于需要保留现有文件的目录

生成的文件格式

每个配置的目录下会生成 messages.json 文件,格式如下:

{
  "sso": {},
  "shared": {}
}

命令行选项

Usage: create-tinyi18n [options]

Options:
  -V, --version        输出版本号
  -c, --config <path>  指定配置文件路径 (默认: "tinyi18n.config.json")
  -h, --help           显示帮助信息

错误处理

  • 如果配置文件不存在,程序会报错并退出
  • 如果配置文件格式错误,程序会显示具体错误信息
  • 如果目录创建失败,程序会显示错误并退出

许可证

MIT