1.0.28 β€’ Published 7 months ago

locale-wizard v1.0.28

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

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"
1.0.28

7 months ago

1.0.27

7 months ago

1.0.26

7 months ago

1.0.25

7 months ago

1.0.24

7 months ago

1.0.23

7 months ago

1.0.22

7 months ago

1.0.21

7 months ago

1.0.20

7 months ago

1.0.19

7 months ago

1.0.18

7 months ago

1.0.17

7 months ago

1.0.16

7 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.5

7 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0-alpha.3

8 months ago

1.0.0-alpha.2

8 months ago

1.0.0-alpha.1

8 months ago

1.0.0-alpha.0

8 months ago