Skip to content

Developer-first CLI that extracts translatable strings from JSX/TSX files, automatically generates i18n JSON files, and rewrites your components to use t().

Notifications You must be signed in to change notification settings

yossTheDev/i18nizer

Repository files navigation

i18nizer 🌍

banner

Node.js Badge oclif Badge TypeScript Badge npm downloads license

i18nizer is a developer-first CLI that extracts translatable strings from JSX/TSX files, automatically generates i18n JSON files, and rewrites your components to use t().

It is designed to be fast, scriptable, CI-friendly, and completely independent from your project configuration.

Supported AI Providers

  • OpenAI
  • Google Gemini
  • Hugging Face (DeepSeek)

🚀 Installation

npm install -g i18nizer

Requires Node.js 18+


🔑 API Keys Configuration

i18nizer keys --setOpenAI <YOUR_OPENAI_API_KEY>
i18nizer keys --setGemini <YOUR_GEMINI_API_KEY>
i18nizer keys --setHF <YOUR_HUGGING_FACE_API_KEY>

Keys are stored inside:

[HOME]/.i18nizer/api-keys.json

⚡ Usage

i18nizer extract <file-path> --locales en,es,fr --provider openai

Flags:

  • --locales → Languages to generate (default: en,es)
  • --provideropenai | gemini | huggingface (optional)

🧩 Example

Input Component

export function Login() {
  return (
    <div>
      <h1>Welcome back</h1>
      <p>Please sign in to continue</p>
      <button>Sign in</button>
    </div>
  );
}

Output Component (Automatically Rewritten)

import { useTranslations } from "next-intl";

export function Login() {
  const t = useTranslations("Login");

  return (
    <div>
      <h1>{t("welcomeBack")}</h1>
      <p>{t("pleaseSignInToContinue")}</p>
      <button>{t("signIn")}</button>
    </div>
  );
}

Generated JSON (.i18nizer/messages/en/Login.json)

{
  "Login": {
    "welcomeBack": "Welcome back",
    "pleaseSignInToContinue": "Please sign in to continue",
    "signIn": "Sign in"
  }
}

📂 Output Structure

.i18nizer/
├─ api-keys.json
├─ tsconfig.json
└─ messages/
   ├─ en/
   │  └─ Login.json
   ├─ es/
   │  └─ Login.json
   └─ fr/
      └─ Login.json

✨ Features

  • Works with JSX & TSX
  • Rewrites components automatically (t("key"))
  • Always generates English camelCase keys
  • Supports any number of locales
  • Isolated TypeScript parsing (no project tsconfig required)
  • Friendly logs, and errors

🔮 Roadmap

  • Configurable output directory
  • Framework support (Vue, Svelte)
  • i18n library presets (next-intl, react-i18next)
  • Watch mode
  • Non-AI fallback mode

⚠️ Notes

  • API keys are never committed
  • JSON files are stored per project in .i18nizer/
  • Designed for incremental adoption

Made with ❤️ by Yoannis Sánchez Soto

About

Developer-first CLI that extracts translatable strings from JSX/TSX files, automatically generates i18n JSON files, and rewrites your components to use t().

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published