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 🙏

© 2024 – Pkg Stats / Ryan Hefner

locale-wizard

v1.0.28

Published

Automatic JSON localization files translator

Downloads

1,897

Readme

Locale Wizard 🧙‍♂️

A powerful tool for managing and auto-translating your application's localization files using OpenAI's GPT models.

Installation

npm install locale-wizard -D

Features

  • 🌍 Supports 70+ languages
  • 🤖 AI-powered translations with context awareness
  • 🧹 Automatic cleanup of unused translation keys
  • ⚡️ Easy integration with existing projects

1. Usage: node.js

import { LocaleWizard } from "locale-wizard";

const config: WizardConfig = {
  sourceLocale: "en",
  targetLocales: ["ru", "es", "de"],
  localesPath: "./src/locales",
  openAiKey: "<your-openai-api-key>"
};

const wizard = new LocaleWizard(config);

Translates all files in sourceLocale to every language in targetLocales

await wizard.translate();

Cleans up any key that exists in any targetLocales locale but doesnt exist in sourceLocale

await wizard.translate();

2. Usage: terminal

Terminal usage requires a file .locale-wizard.json in the root of your project. Format is similar to type WizardConfig

{
  "sourceLocale": "en",
  "targetLocales": ["ru", "es", "de"],
  "localesPath": "./src/locales",
  "openAiKey": "<your-openai-api-key>"
}

To translate enter:

locale-wizard --translate

To clean extra keys:

locale-wizard --clean

Configuration

interface WizardConfig {
  // Source language for translations
  sourceLocale: Locale;
  
  // Languages you want to translate into
  targetLocales: Locale[];
  
  // Directory containing your locale files
  localesPath: string;
  
  // Namespaces to exclude from translation
  ignoreNamespaces?: string[];
  
  // Your OpenAI API key
  // Get it at: https://platform.openai.com/api-keys
  openAiKey?: string;
  
  // OpenAI model to use (defaults to "gpt-4")
  chatGptModel?: OpenAI.ChatModel;
}

Supported Languages

The package supports 70+ languages including:

  • 🇺🇸 English (en)
  • 🇪🇸 Spanish (es)
  • 🇷🇺 Russian (ru)
  • 🇩🇪 German (de)
  • 🇨🇳 Chinese (zh)
  • 🇯🇵 Japanese (ja)
  • ...and many more!

See full list of supported languages

Best Practices

  1. Always backup your locale files before running translations
  2. Start with a small set of translations to verify quality
  3. Review automated translations for context-specific accuracy
  4. Use ignoreNamespaces for technical strings that shouldn't be translated

License

MIT © Nikolai Smolianinov


type Locale = "en" | "ru" | "es" | "zh" | "it" | "ar" | "de" | "fr" | "pt" | "hi" | 
  "ja" | "ko" | "tr" | "nl" | "sv" | "da" | "no" | "fi" | "pl" | "cs" | "sr" | 
  "bg" | "hr" | "el" | "he" | "hu" | "id" | "ms" | "ro" | "sk" | "sl" | "th" | 
  "vi" | "fa" | "ur" | "bn" | "ta" | "te" | "ml" | "kn" | "mr" | "gu" | "ka" | 
  "az" | "be" | "hy" | "et" | "lv" | "lt" | "af" | "sq" | "am" | "eu" | "my" | 
  "ca" | "km" | "ky" | "lo" | "mk" | "mn" | "ne" | "pa" | "si" | "tg" | "tk" | 
  "uz" | "cy" | "yi" | "zu" | "sw" | "so" | "ha" | "ig" | "yo" | "gl" | "is" | 
  "lb" | "mt" | "ps"