linguaisync
v0.1.2
Published
AI-powered translation synchronization tool using OpenAI to keep translation files in sync
Maintainers
Readme
linguAIsync
AI-powered translation synchronization tool. Automatically detects missing translations and uses OpenAI to translate them while preserving formatting and placeholders.
Installation
npm install linguaisyncQuick Start
- Set OpenAI API key
export OPENAI_API_KEY="sk-your-api-key"- Create
linguaisync.config.js
const path = require('path');
module.exports = {
localesDir: path.join(__dirname, 'public/locales'),
baseLanguage: 'en',
translationFiles: ['translation.json'],
};- Directory structure
locales/
├── en/
│ └── translation.json
└── es/
└── translation.json- Run
# Preview changes
npx linguaisync --all --dry-run
# Sync all languages
npx linguaisync --all
# Sync specific languages
npx linguaisync --lang es,fr,deCLI Options
linguaisync --all # Process all languages
linguaisync --lang es,fr # Process specific languages
linguaisync --all --dry-run # Preview without changes
linguaisync --all --dry-run --verbose # Show detailed output
linguaisync --all --dry-run --output missing.json # Export to file
linguaisync --config custom.js # Use custom config
linguaisync --locales-dir ./i18n # Override locales pathConfiguration
JavaScript config (linguaisync.config.js):
const path = require('path');
module.exports = {
localesDir: path.join(__dirname, 'public/locales'),
baseLanguage: 'en',
translationFiles: ['translation.json', 'common.json'],
batchSize: 20,
model: 'gpt-4o-mini',
temperature: 0.3,
};JSON config (linguaisync.config.json):
{
"localesDir": "./public/locales",
"baseLanguage": "en",
"translationFiles": ["translation.json"],
"batchSize": 20
}Programmatic API
const { createConfig, syncLanguages, analyzeLanguages } = require('linguaisync');
const config = createConfig({
localesDir: './locales',
baseLanguage: 'en',
});
// Analyze (dry run)
const missing = analyzeLanguages(config, ['es', 'fr'], true);
// Sync translations
await syncLanguages(config, ['es', 'fr']);Supported Languages
| Language | Code | Language | Code | Language | Code | |----------|------|----------|------|----------|------| | Arabic | ar | German | de | Japanese | jp | | Bulgarian | bg | Greek | el | Korean | ko | | Chinese | zh | Indonesian | id | Dutch | nl | | Danish | da | Italian | it | Norwegian | no | | Spanish | es | Polish | pl | Ukrainian | ua | | Finnish | fi | Portuguese | pt | Vietnamese | vi | | French | fr | Romanian | ro | | | | | | Russian | ru | | | | | | Slovenian | sl | | | | | | Swedish | sv | | | | | | Turkish | tr | | |
NPM Scripts
Add to package.json:
{
"scripts": {
"i18n:check": "linguaisync --all --dry-run --verbose",
"i18n:sync": "linguaisync --all"
}
}Features
- 🤖 AI-powered translations via OpenAI
- 🔄 Automatic missing key detection
- 🎯 Smart batching for API efficiency
- 📦 Multi-file support
- 🔑 Preserves placeholders (
{{var}}) and HTML - 🧪 Dry run mode
- 💾 Export to JSON
License
This project is licensed under the MIT License.
🌟 Please check my other projects!
- tududi - Productivity made simple
- Reconya - Network reconnaissance and asset discovery tool
- BreachHarbor - Cybersecurity suite for digital asset protection
- Hevetra - Digital tracking for child health milestones
README created by Chris Veleris for linguAIsync.
