An AI-powered internationalization tool that automatically translates JSON locale files using OpenAI's GPT-4 model. Localiser supports batch translation across multiple languages and namespaces with a simple CLI interface.
- 🤖 AI-Powered Translation: Uses OpenAI's GPT-4 for high-quality translations
- 📁 Namespace Management: Organize translations by namespaces (e.g., home, settings, common)
- 📊 Real-time Progress: Visual progress bars showing translation status
- ⚡ CLI Interface: Simple command-line interface for easy integration
- 🔧 Configurable: Flexible configuration through JSON files
- 🗂️ Dynamic folder structure support: Now supports lang/namespace.json, lang.json is not supported yet
- 💿 Optimized translation: Translate only missing keys in the target language files (add a flag to override existing translations)
- 🤖 AI Model selection: Allow users to choose between different OpenAI models (e.g., GPT-3.5, GPT-4)
- 🎬 Init command: Add a command to initialize the project with default configuration json file
Feel free to contribute to the project by submitting issues or pull requests!
- Node.js (v16 or higher)
- OpenAI API key (Add this to
.envfile of your project)
npm install -g @pulimoodan/localiserCreate a .env file in your project root:
OPENAI_API_KEY=your_openai_api_key_hereCreate a localiser.json file to configure your translation settings:
{
"directory": "public/locales",
"sourceLanguage": "en",
"languages": ["fr", "es", "de", "it", "pt", "zh", "ja", "ru"],
"namespaces": ["home", "settings"]
}directory: Path to your locales directorysourceLanguage: Source language code (e.g., "en")languages: Array of target language codes to translate tonamespaces: Array of namespace names to translate
Translate all configured languages and namespaces:
loaliserloaliser --language fr,esloaliser --namespace home,settingsloaliser --language fr --namespace homelocaliser --config custom-config.json| Option | Short | Description | Default |
|---|---|---|---|
--language |
-l |
Target languages code | All configured languages |
--namespace |
-n |
Specific namespaces to translate | All configured namespaces |
--config |
-c |
Path to configuration file | localiser.json |
commander: CLI argument parsingdotenv: Environment variable managementfs-extra: Enhanced file system operationsopenai: OpenAI API client
ISC License
pulimoodan
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For issues and questions, please open an issue on the GitHub repository.