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

i18n-key-sync

v1.0.2

Published

CLI and library to merge and sync missing keys across i18n JSON files

Readme

# i18n-key-sync

A CLI tool to **sync and validate i18n translation keys** across multiple JSON locale files.  
It ensures that all locale files have the same keys, detects missing or extra keys, and optionally fixes discrepancies.

---

## ✨ Features

- ✅ Detects missing keys in translation files  
- ✅ Detects extra/unexpected keys  
- ✅ Optionally adds missing keys with indicators (e.g., `__MISSING__`)  
- ✅ Works with any number of locale JSON files  
- ✅ Provides a clear CLI output with summary  
- ✅ Can be added as a **dev dependency** and used in CI pipelines  

---

## 📦 Installation

```bash
npm install --save-dev i18n-key-sync

or with yarn:

yarn add -D i18n-key-sync

🚀 Usage

Command

i18n-key-sync [options] <locales...>

Options

| Option | Description | | -------------------------- | ------------------------------------------------------ | | -r, --reference <file> | Specify the reference locale file (default: en.json) | | -f, --fix | Automatically add missing keys with an indicator value | | -o, --output <directory> | Output directory for fixed locale files | | -h, --help | Show help | | -v, --version | Show version |


🛠 Example

Given the following files:

locales/en.json

{
  "hello": "Hello",
  "bye": "Goodbye"
}

locales/de.json

{
  "hello": "Hallo"
}

✅ Check for missing keys:

i18n-key-sync -r locales/en.json locales/*.json

Output:

[de.json] Missing key: bye

✅ Auto-fix missing keys:

i18n-key-sync -r locales/en.json locales/*.json --fix

Result (de.json):

{
  "hello": "Hallo",
  "bye": "__MISSING__ Goodbye"
}

📂 Project Structure

src/
 ├─ cli/             # CLI entry
 │   └─ cli.ts
 ├─ core/            # Core logic
 │   └─ I18nFixer.ts
 └─ utils/           # File utilities
     └─ fileUtils.ts

tests/
 ├─ core/            # Core tests
 │   └─ I18nFixer.spec.ts
 └─ utils/
     └─ fileUtils.spec.ts

🔧 Adding as an NPM Script

You can add it to your package.json:

{
  "scripts": {
    "i18n:check": "i18n-key-sync -r locales/en.json locales/*.json"
  }
}

Run:

npm run i18n:check

🧪 Running Tests

This project uses Mocha + Chai + NYC for 100% coverage.

npm test

🤝 Contributing

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature-name)
  3. Commit your changes (git commit -m 'Add feature')
  4. Push to your branch (git push origin feature-name)
  5. Open a Pull Request

📄 License

MIT License © 2025 [Fahad Mustjab]


💡 Roadmap

  • [ ] Support nested JSON key detection
  • [ ] Support YAML files
  • [ ] Add interactive mode for fixing keys
  • [ ] Provide VSCode extension for real-time i18n sync checks

🚀 Maintained with ❤️ by fahadmustjab