{"_id":"@cgaravitoq/i18n-ai","name":"@cgaravitoq/i18n-ai","dist-tags":{"latest":"0.2.3"},"versions":{"0.2.3":{"name":"@cgaravitoq/i18n-ai","version":"0.2.3","description":"AI-powered i18n translation and synchronization library","main":"dist/index.js","module":"dist/index.mjs","types":"dist/index.d.ts","bin":{"i18n-ai":"dist/cli.js"},"publishConfig":{"access":"public"},"scripts":{"build":"tsup","dev":"tsup --watch","start":"node dist/cli.js","lint":"tsc --noEmit"},"repository":{"type":"git","url":"git+https://github.com/CarlosPProjects/i18n-ai.git"},"keywords":["i18n","ai","translation","automation"],"author":{"name":"Carlos Garavito"},"license":"ISC","dependencies":{"@openrouter/ai-sdk-provider":"^1.5.4","@t3-oss/env-core":"^0.13.10","ai":"^6.0.37","chalk":"^5.6.2","commander":"^14.0.2","dotenv":"^17.2.3","p-queue":"^9.1.0","prompts":"^2.4.2","proper-lockfile":"^4.1.2","zod":"^4.3.5"},"devDependencies":{"@types/node":"^25.0.9","@types/prompts":"^2.4.9","@types/proper-lockfile":"^4.1.4","tsup":"^8.5.1","tsx":"^4.21.0","typescript":"^5.9.3"},"_id":"@cgaravitoq/i18n-ai@0.2.3","bugs":{"url":"https://github.com/CarlosPProjects/i18n-ai/issues"},"homepage":"https://github.com/CarlosPProjects/i18n-ai#readme","_nodeVersion":"26.1.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-JltxStMZqIXeasivH996uFAUegxSVdlRgCg2RIRdMZEmR1e01BA7DAGUm0xr05JRoMVVRS0obphmPYor0gy+Ng==","shasum":"053aa99262e97da0b629b402415f7417dede0da9","tarball":"https://registry.npmjs.org/@cgaravitoq/i18n-ai/-/i18n-ai-0.2.3.tgz","fileCount":11,"unpackedSize":49475,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDD07+65PhOfDvzWrawx4h6FwMxIs4sw9dv3B5bFhCRAgIgFNxFDMYm70Kr7n3BDC/vQymPNig+xWyshlMhBi4laOo="}]},"_npmUser":{"name":"cgaravito.dev","email":"cg9822@gmail.com"},"directories":{},"maintainers":[{"name":"cgaravito.dev","email":"cg9822@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/i18n-ai_0.2.3_1780064222494_0.8904627894779091"},"_hasShrinkwrap":false}},"time":{"created":"2026-05-29T14:17:02.364Z","0.2.3":"2026-05-29T14:17:02.643Z","modified":"2026-05-29T14:17:02.943Z"},"maintainers":[{"name":"cgaravito.dev","email":"cg9822@gmail.com"}],"description":"AI-powered i18n translation and synchronization library","homepage":"https://github.com/CarlosPProjects/i18n-ai#readme","keywords":["i18n","ai","translation","automation"],"repository":{"type":"git","url":"git+https://github.com/CarlosPProjects/i18n-ai.git"},"author":{"name":"Carlos Garavito"},"bugs":{"url":"https://github.com/CarlosPProjects/i18n-ai/issues"},"license":"ISC","readme":"# i18n-ai\n\nAI-powered internationalization (i18n) translation and synchronization library. This tool automates the translation of your JSON message files using AI, keeping them synchronized with your base locale.\n\n## Features\n\n- 🤖 **AI-Powered**: Uses Google Gemini (via OpenRouter) to generate context-aware translations.\n- ⚡ **Parallel Processing**: Translations run concurrently for maximum speed (5x faster).\n- 🔄 **Smart Synchronization**: Detects new, modified, and obsolete keys.\n- ⛔ **Variable Protection**: Automatically preserves variables like `{name}` or `{count}`.\n- 🔒 **Lock File System**: Prevents unnecessary re-translations of already translated content.\n- 🧩 **Framework Agnostic**: Works with any i18n library that uses JSON files (next-intl, react-i18next, etc.).\n\n## Installation\n\n```bash\nbun add @ccgp/i18n-ai\n# or\nnpm install @ccgp/i18n-ai\n```\n\n## Usage\n\n### CLI\n\nThe easiest way to use `i18n-ai` is via the CLI.\n\n1. **Initialize configuration:**\n\n```bash\nbun x i18n-ai init\n```\n\nThis will create an `i18n-ai.config.json` file:\n\n```json\n{\n  \"defaultLocale\": \"en\",\n  \"locales\": [\"en\", \"es\", \"fr\"],\n  \"messagesDir\": \"messages\"\n}\n```\n\n2. **Run synchronization:**\n\n```bash\nbun x i18n-ai sync\n```\n\n### CLI Options\n\nThe `sync` command supports these options:\n\n| Option | Description |\n|--------|-------------|\n| `-d, --dir <path>` | Messages directory (default: `messages`) |\n| `-l, --locales <items>` | Comma-separated list of locales |\n| `--default <locale>` | Default locale (default: `en`) |\n| `--lock <path>` | Lock file path (default: `translation-lock.json`) |\n| `--api-key <key>` | OpenRouter API key (or set `OPENROUTER_API_KEY`) |\n| `--model <model>` | AI model to use (default: `google/gemini-2.5-flash`) |\n\nExample with custom options:\n\n```bash\nbun x i18n-ai sync --locales es,fr,de --model anthropic/claude-3-haiku\n```\n\n### Environment Variables\n\nYou need to provide an API key for the AI provider.\n\nCreate a `.env` file:\n\n```env\nOPENROUTER_API_KEY=your_api_key\n```\n\n### Automate with GitHub Actions\n\nYou can automate translations whenever you push changes to your default locale.\n\nCreate `.github/workflows/i18n-translate.yml`:\n\n```yaml\nname: AI Translation Sync\n\non:\n  push:\n    paths:\n      - 'public/messages/en.json' # Monitor ONLY source locale\n\njobs:\n  translate:\n    runs-on: ubuntu-latest\n    permissions:\n      contents: write\n    steps:\n      - uses: actions/checkout@v4\n      - uses: oven-sh/setup-bun@v1\n       - run: bun install\n       - run: bun x i18n-ai sync --api-key ${{ secrets.OPENROUTER_API_KEY }}\n      - run: |\n          git config --global user.name \"github-actions[bot]\"\n          git config --global user.email \"github-actions[bot]@users.noreply.github.com\"\n          if [[ -n $(git status -s) ]]; then\n            git add public/messages/*.json translation-lock.json\n            git commit -m \"chore(i18n): update translations [skip ci]\"\n            git push\n          fi\n```\n\n## Programmatic Usage\n\nYou can also use the library programmatically:\n\n```typescript\nimport { TranslationService } from '@ccgp/i18n-ai';\nimport { resolve } from 'path';\n\nconst service = new TranslationService({\n  locales: ['en', 'es', 'fr'],\n  defaultLocale: 'en',\n  messagesDir: resolve(process.cwd(), 'messages'),\n  lockFilePath: resolve(process.cwd(), 'translation-lock.json'),\n  apiKey: process.env.OPENROUTER_API_KEY\n});\n\nawait service.sync();\n```\n\n## License\n\nISC\n","readmeFilename":"README.md","_rev":"1-bed84af10249da2b993f4af86795f9fd"}