locale-wizard v1.0.28
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
- Always backup your locale files before running translations
- Start with a small set of translations to verify quality
- Review automated translations for context-specific accuracy
- 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"
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago