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

i18n-sheet-convert

v1.0.1

Published

一个用于在i18n JSON文件和Excel文件之间进行转换的工具

Downloads

7

Readme

i18n-sheet-convert

一个用于在i18n JSON文件和Excel文件之间进行转换的工具。这个工具通过在JSON格式和Excel电子表格之间进行转换,帮助你管理国际化(i18n)翻译。

功能特点

  • 将i18n JSON文件转换为Excel格式
  • 将Excel文件转换回i18n JSON格式
  • 支持嵌套的JSON结构
  • 从Excel转换回时保持JSON结构
  • Excel中自动调整列宽
  • 从本地化目录自动检测语言
  • 支持自定义语言配置
  • 支持多种语言(不仅仅是中文和英文)

安装

npm install i18n-sheet-convert
# 或者
yarn add i18n-sheet-convert
# 或者
pnpm add i18n-sheet-convert

使用方法

自动检测语言

import { I18nConverter } from 'i18n-sheet-convert';

// 转换器将自动检测本地化目录中的语言文件
const converter = new I18nConverter({
  localesPath: './locales',  // 包含JSON文件的目录
  outputPath: './output'     // Excel输出目录
});

// 将JSON转换为Excel
await converter.jsonToExcel();

// 将Excel转换回JSON
await converter.excelToJson();

手动语言配置

import { I18nConverter } from 'i18n-sheet-convert';

const converter = new I18nConverter({
  localesPath: './locales',
  outputPath: './output',
  languages: [
    { code: 'zh-CN', name: '中文' },
    { code: 'en', name: 'English' },
    { code: 'ja', name: '日本語' },
    // 根据需要添加更多语言
  ]
});

await converter.jsonToExcel();
await converter.excelToJson();

文件结构

你的本地化目录应该包含以语言代码命名的JSON文件:

  • zh-CN.json:中文翻译
  • en.json:英文翻译
  • ja.json:日语翻译
  • 等等

Excel文件将在你的输出目录中生成为 translations.xlsx

JSON格式示例

// zh-CN.json
{
  "common": {
    "submit": "提交",
    "cancel": "取消"
  }
}

// en.json
{
  "common": {
    "submit": "Submit",
    "cancel": "Cancel"
  }
}

// ja.json
{
  "common": {
    "submit": "送信",
    "cancel": "キャンセル"
  }
}

Excel格式

生成的Excel文件将包含以下列:

  • key:翻译键名(例如:"common.submit")
  • 每种语言一列(例如:"zh-CN"、"en"、"ja")

API

I18nConverter

构造函数

constructor(options: I18nConverterOptions)

选项:

  • localesPath:包含JSON文件的目录路径
  • outputPath:Excel文件保存的路径
  • languages?:可选的语言配置数组:
    interface I18nLanguageConfig {
      code: string;    // 语言代码(例如:'en','zh-CN')
      name: string;    // 显示名称(例如:'English','中文')
    }

方法

jsonToExcel()

将JSON文件转换为Excel格式。

excelToJson()

将Excel文件转换回JSON格式。