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-auto-translator

v1.2.1

Published

A package to automatically translate i18n JSON files using AI.

Readme

i18n-auto-translator

i18n-auto-translator

Description

i18n-auto-translator is a powerful tool designed to automatically translate i18n JSON files using various AI language models (OpenAI, Anthropic Claude). This package helps you maintain multilingual support in your applications by filling in missing translations and tidying up your JSON files.

Installation

To install the package, you need to have Node.js and npm installed on your machine. Then, you can install the dependencies by running:

npm install

Usage

Translating JSON Files

To translate your i18n JSON files, you can use the following script:

# Note: Use -- before arguments when using npm run
npm run translate -- --apiKey=YOUR_API_KEY --localesDir=./path/to/your/i18n --model=gpt-3.5-turbo --provider=openai --languages=fr,es,de

# Enable debug mode for more detailed logs
DEBUG=true npm run translate -- --provider=bedrock --model=anthropic.claude-v2 --languages=fr,es,de

Or using the shorter argument aliases:

npm run translate -k YOUR_API_KEY -d ./path/to/your/i18n -m gpt-3.5-turbo -p openai -l fr,es,de

To see all available options:

npm run translate -- --help

This script will:

  1. Create language files (if they don't exist) for each specified language
  2. Process each language file and translate any missing keys
  3. Maintain existing translations
  4. Beautify the JSON output

If no languages are specified, the script will process all existing JSON files in the locales directory.

You can also use npx to run the translation script without installing the package globally:

npx i18n-auto-translator translate --apiKey=YOUR_API_KEY --localesDir=./path/to/your/i18n --model=gpt-3.5-turbo --provider=openai --languages=fr,es,de

Tidying Up JSON Files

To tidy up your JSON files and ensure they are properly formatted, you can use the following script:

npm run tidy --localesDir=./path/to/your/i18n

This script will beautify all JSON files in the specified localesDir directory, making them easier to read and maintain.

Alternatively, you can use npx to run the tidy script without installing the package globally:

npx i18n-auto-translator tidy --localesDir=./path/to/your/i18n

Using npx

npx is a tool that comes with npm (since version 5.2.0) and allows you to run commands from npm packages without globally installing them. This can be useful for running scripts like the ones provided by i18n-auto-translator without polluting your global npm installation.

Configuration

The package uses environment variables to configure the AI provider settings. You can either pass these as command-line arguments or set them in a .env file in the root directory of your project:

AI_API_KEY=your_api_key
AI_MODEL=gpt-3.5-turbo
AI_PROVIDER=openai
LOCALES_DIR=./path/to/your/i18n
TARGET_LANGUAGES=fr,es,de  # Optional: comma-separated list of target languages

Supported AI Providers

OpenAI

  • Provider: openai
  • Models: gpt-3.5-turbo, gpt-4, etc.
  • API Key: OpenAI API key

Anthropic Claude

  • Provider: claude
  • Models: claude-instant-1, claude-2, etc.
  • API Key: Anthropic API key

Amazon Bedrock

  • Provider: bedrock
  • Models:
    • anthropic.claude-v2
    • anthropic.claude-instant-v1
    • amazon.titan-text-express-v1
  • Credentials: AWS Access Key ID and Secret Access Key
  • Region: AWS Region where Bedrock is available

Example using Claude:

npm run translate -k YOUR_ANTHROPIC_KEY -m claude-2 -p claude -d ./path/to/your/i18n -l fr,es,de

Example using Amazon Bedrock:

# Using long arguments
npm run translate -- \
  --provider=bedrock \
  --model=anthropic.claude-v2 \
  --awsAccessKey=YOUR_AWS_ACCESS_KEY \
  --awsSecretKey=YOUR_AWS_SECRET_KEY \
  --awsRegion=us-east-1 \
  --languages=fr,es,de

# Using short arguments
npm run translate -- \
  -p bedrock \
  -m anthropic.claude-v2 \
  --awsAccessKey=YOUR_AWS_ACCESS_KEY \
  --awsSecretKey=YOUR_AWS_SECRET_KEY \
  --awsRegion=us-east-1 \
  -l fr,es,de

# With debug mode
DEBUG=true npm run translate -- \
  --provider=bedrock \
  --model=anthropic.claude-v2 \
  --awsAccessKey=YOUR_AWS_ACCESS_KEY \
  --awsSecretKey=YOUR_AWS_SECRET_KEY \
  --awsRegion=us-east-1 \
  --languages=fr,es,de

You can also configure AWS credentials using environment variables:

AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_REGION=us-east-1
AI_PROVIDER=bedrock
AI_MODEL=anthropic.claude-v2

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Created by Tarik Ermis. For any inquiries, please contact [email protected].