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-ai-diff

v1.0.1

Published

Diff-powered i18n CLI: only translates changed keys. Source snapshots + cache = minimal API cost. Watch mode, skip patterns, any LLM.

Readme

i18n-ai-diff

中文 | English

Frontend projects with i18n typically maintain a set of JSON files in English as the base language. Translating them into other languages requires manual work or outsourcing — expensive, slow, and error-prone.

i18n-ai-diff automates this with LLM: it watches your English source files, precisely detects which keys are added, modified, or deleted, and only calls the translation API for the changes. Results are written back to the corresponding language JSON files. Translation cache + source file snapshots ensure zero overhead on repeated runs. The skipKeys config preserves brand names and other fields that should remain untranslated. Compatible with any OpenAI-compatible API service.

Install

npm install i18n-ai-diff

Translate

Scans the base language directory, diffs against target language files, and only translates added or modified keys. Zero API calls when nothing has changed.

npx i18n-ai-diff

Translate + Watch

Runs a full translation first, then continuously watches for base language file changes and auto-syncs translations to all target languages. Ideal for development. Ctrl+C to exit.

npx i18n-ai-diff -w

Force Full Retranslation

Clears cache and snapshots, ignores existing translations, and retranslates all keys via LLM. Use when switching models or when a full quality refresh is needed.

npx i18n-ai-diff -f

Specify Languages

Overrides targetLangs from the config file. Only translates the specified languages. Accepts multiple BCP 47 language codes.

npx i18n-ai-diff -l fr ja ko

Configuration

Create i18n-translate.config.ts:

import { defineConfig } from 'i18n-ai-diff';

export default defineConfig({
  baseLang: 'en',
  targetLangs: ['zh', 'ja', 'ko', 'fr', 'de', 'es', 'it', 'pt', 'ru'],
  localesDir: './src/i18n/messages',

  skipKeys: [
    'common.brandName',
    'footer.**',
  ],

  llm: {
    apiKey: process.env.OPENAI_API_KEY || '',
    model: 'gpt-4o-mini',
    baseURL: 'https://api.openai.com/v1',
    maxTokens: 4096,
    temperature: 0.3,
    timeout: 30000,
    retries: 3,
  },

  concurrency: 5,
  batchSize: 20,
  cachePath: '.i18n-translate-cache.json',
});

Other options:

npx i18n-ai-diff -c ./path/to/config.ts   # Custom config file
npx i18n-ai-diff --verbose                 # Verbose logging

Directory Structure

locales/
├── en/           # Base language
│   ├── common.json
│   └── pages/
│       └── home.json
├── de/           # Target language (auto-translated)
│   └── ...
└── ja/
    └── ...

How It Works

  • Detects changes in en via source file snapshots — only translates added and modified keys
  • Deleted keys are automatically removed from target language files
  • Translation results are cached — identical text is never sent to the API twice
  • Compatible with any OpenAI-standard API

Troubleshooting

Batch translation failed: Translation failed after N retries: Request was aborted.

The request did not complete within the timeout and was aborted. Troubleshoot in order:

  1. Check your network proxy/VPN — make sure the proxy is active and the current region can reach your LLM service (e.g. OpenAI requires a non-restricted region, while Tencent HunYuan has poor connectivity in overseas nodes)
  2. LLM service is slow or unstable
  3. timeout is too low (default 30000ms)
  4. batchSize is too large, sending too much text per request

Adjust config:

llm: {
  timeout: 60000,   // Increase timeout (ms)
  retries: 5,       // More retry attempts
},
batchSize: 10,      // Smaller batch size
concurrency: 3,     // Lower concurrency

LLM returned empty content

The LLM returned an empty response. Usually caused by rate limiting or prompt being too long. Reduce batchSize or switch to a more stable model.

Config file not found

No config file was found. Make sure i18n-translate.config.ts exists in the project root, or specify a path with -c.

llm.apiKey is required

API key is not configured. Set llm.apiKey in the config file, or set the OPENAI_API_KEY environment variable.

Cache version mismatch, resetting

The cache file version doesn't match (usually after an upgrade). The cache resets automatically. The first run will retranslate all keys; subsequent runs resume incremental mode.

N keys failed, see .i18n-translate-failures.md

Some keys failed to translate. Check .i18n-translate-failures.md in the project root for details. Run npx i18n-ai-diff again to automatically retry the failed keys.

License

MIT