Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement โ†’
Sign In

localize-ai

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

localize-ai - npm Package Compare versions

Comparing version
1.2.1
to
1.2.2
+285
README.md
# ๐Ÿš€ localize-ai
**Plug & Play AI-powered localization for React apps with lazy loading & per-locale splitting**
> Context-aware AI localization with multi-provider support โšก
Automatically extract, translate, and serve multilingual UI โ€” powered by AI โšก
Designed for performance: no unnecessary data, no re-fetching, minimal bundle impact.
---
## โœจ Features
### ๐Ÿ”ง Core
* ๐Ÿ” Auto-extract static text (`t("...")`)
* ๐ŸŒ AI-powered translations (OpenAI, Gemini)
* โšก Incremental translation (only new strings/languages)
### โšก Performance
* โšก Lazy loading (loads only required language)
* ๐Ÿ“ฆ Per-locale splitting (smaller bundles)
* ๐Ÿš€ Built-in caching (no redundant fetches)
### โš›๏ธ Developer Experience
* ๐Ÿง  Zero-config runtime
* โš›๏ธ React hooks + context
* ๐Ÿง  Context-aware translations
* ๐Ÿ’ธ Cost optimized (no re-translation)
---
## โšก Performance Optimizations
### localize-ai is optimized for production:
* **Per-locale splitting**
โ†’ Each language is stored separately (translations_en.json, translations_hi.json)
* **Lazy loading**
โ†’ Only loads the active language instead of all translations
* **Caching**
โ†’ Prevents repeated fetches and improves performance
๐Ÿ‘‰ This ensures fast load times and minimal bundle size.
---
## ๐Ÿ“ฆ Installation
```bash
npm install localize-ai
```
---
## โš™๏ธ Setup (2 steps)
### 1๏ธโƒฃ Create config
```js
// localize.config.js
export default {
sourceLanguage: "en",
translationLanguages: ["hi", "fr"],
provider: "gemini", // or "openai"
apikey: "VITE_GEMINI_API_KEY",
context: "E-commerce checkout UI for buying products"
};
```
๐Ÿ‘‰ Providing context improves translation accuracy by helping AI understand intent (e.g., "Charge" in payments vs battery).
---
### 2๏ธโƒฃ Add your API key
```env
VITE_GEMINI_API_KEY=your_api_key_here
```
---
## ๐Ÿš€ Usage
### Step 1: Initialize
```bash
npx localize-ai init
```
---
### Step 2: Extract & translate
```bash
npx localize-ai translate
```
This will:
* scan your codebase
* extract t("text")
* generate translations
* create per-language translation files:
```
public/
โ”œโ”€โ”€ translations_en.json
โ”œโ”€โ”€ translations_hi.json
โ”œโ”€โ”€ translations_fr.json
โ””โ”€โ”€ ...
localize.runtime.json
```
---
### Step 3: Wrap your app
```tsx
import { LanguageContextProvider } from "localize-ai";
<LanguageContextProvider>
<App />
</LanguageContextProvider>
```
---
### Step 4: Use translations
```tsx
import { useTranslation } from "localize-ai";
function App() {
const { t } = useTranslation();
return <h1>{t("Hello world")}</h1>;
}
```
---
## ๐ŸŒ Change language
```tsx
const { setLang } = useTranslation();
setLang("fr"); // switch language
```
---
## ๐Ÿง  How it works
```text
Code โ†’ Extract โ†’ Clean โ†’ AI Translate โ†’ JSON โ†’ React Context โ†’ UI
```
* Only new strings are translated
* Only missing languages are generated
* Existing translations are reused
---
## ๐Ÿ“ Output
```bash
public/
โ”œโ”€โ”€ translations_en.json
โ”œโ”€โ”€ translations_hi.json
โ”œโ”€โ”€ translations_fr.json
โ””โ”€โ”€ ...
```
---
## โšก Example
```tsx
<h1>{t("Get started")}</h1>
```
โžก๏ธ Automatically becomes:
```json
{
"Get started": {
"en": "Get started",
"hi": "เคถเฅเคฐเฅ‚ เค•เคฐเฅ‡เค‚",
"fr": "Commencer"
}
}
```
---
## ๐Ÿ›  CLI Commands
```bash
npx localize-ai init # generate runtime config
npx localize-ai translate # extract + translate
```
---
## ๐ŸŽฏ Why localize-ai?
| Feature | localize-ai | traditional i18n |
| ------------------- | ----------- | ---------------- |
| Auto extraction | โœ… | โŒ |
| AI translation | โœ… | โŒ |
| Incremental updates | โœ… | โŒ |
| Setup time | โšก minutes | โณ hours |
---
## โš ๏ธ Notes
* Only static strings inside `t("...")` are extracted
* Ensure `public/` folder exists
* API key is required only for translation step
---
## ๐Ÿ—บ Roadmap
### Core Improvements
* [ ] AST-based extraction (no regex)
* [ ] Better error handling & retry logic for failed translations
* [ ] CLI UX improvements (spinners, better logs)
### Performance & DX
* [x] Lazy loading translations
* [x] Per-locale splitting
* [x] Built-in caching
* [ ] CDN support for translation files
### Features
* [x] Multi-provider support (OpenAI, Gemini)
* [ ] Fallback providers (auto-switch if one fails)
* [ ] Custom translation rules (skip/override specific keys)
* [ ] Namespace support (group translations)
### Developer Experience
* [ ] VS Code extension (highlight untranslated strings)
* [ ] Debug mode (show missing translations in UI)
* [ ] CLI dry-run mode
### Future Ideas
* [ ] Support for frameworks beyond React (Next.js, Vue)
* [ ] Dashboard for managing translations
* [ ] Analytics (missing keys, usage tracking)
---
## ๐Ÿค Contributing
PRs welcome! Feel free to open issues or suggest improvements.
---
## ๐Ÿ“„ License
MIT
---
## ๐Ÿ’ฌ Author
**Parth Gupta**
---
## โญ Support
If you like this project:
๐Ÿ‘‰ Star the repo
๐Ÿ‘‰ Share with developers
๐Ÿ‘‰ Give feedback
---
+2
-2
{
"name": "localize-ai",
"version": "1.2.1",
"version": "1.2.2",
"description": "AI-powered React localization with context-aware translations, multi-provider support, lazy loading, and per-locale splitting",

@@ -10,3 +10,3 @@ "main": "dist/index.js",

"dist",
"readme.md"
"README.md"
],

@@ -13,0 +13,0 @@ "module": "dist/index.js",

# ๐Ÿš€ localize-ai
**Plug & Play AI-powered localization for React apps with lazy loading & per-locale splitting**
> Context-aware AI localization with multi-provider support โšก
Automatically extract, translate, and serve multilingual UI โ€” powered by AI โšก
Designed for performance: no unnecessary data, no re-fetching, minimal bundle impact.
---
## โœจ Features
### ๐Ÿ”ง Core
* ๐Ÿ” Auto-extract static text (`t("...")`)
* ๐ŸŒ AI-powered translations (OpenAI, Gemini)
* โšก Incremental translation (only new strings/languages)
### โšก Performance
* โšก Lazy loading (loads only required language)
* ๐Ÿ“ฆ Per-locale splitting (smaller bundles)
* ๐Ÿš€ Built-in caching (no redundant fetches)
### โš›๏ธ Developer Experience
* ๐Ÿง  Zero-config runtime
* โš›๏ธ React hooks + context
* ๐Ÿง  Context-aware translations
* ๐Ÿ’ธ Cost optimized (no re-translation)
---
## โšก Performance Optimizations
### localize-ai is optimized for production:
* **Per-locale splitting**
โ†’ Each language is stored separately (translations_en.json, translations_hi.json)
* **Lazy loading**
โ†’ Only loads the active language instead of all translations
* **Caching**
โ†’ Prevents repeated fetches and improves performance
๐Ÿ‘‰ This ensures fast load times and minimal bundle size.
---
## ๐Ÿ“ฆ Installation
```bash
npm install localize-ai
```
---
## โš™๏ธ Setup (2 steps)
### 1๏ธโƒฃ Create config
```js
// localize.config.js
export default {
sourceLanguage: "en",
translationLanguages: ["hi", "fr"],
provider: "gemini", // or "openai"
apikey: "VITE_GEMINI_API_KEY",
context: "E-commerce checkout UI for buying products"
};
```
๐Ÿ‘‰ Providing context improves translation accuracy by helping AI understand intent (e.g., "Charge" in payments vs battery).
---
### 2๏ธโƒฃ Add your API key
```env
VITE_GEMINI_API_KEY=your_api_key_here
```
---
## ๐Ÿš€ Usage
### Step 1: Initialize
```bash
npx localize-ai init
```
---
### Step 2: Extract & translate
```bash
npx localize-ai translate
```
This will:
* scan your codebase
* extract t("text")
* generate translations
* create per-language translation files:
```
public/
โ”œโ”€โ”€ translations_en.json
โ”œโ”€โ”€ translations_hi.json
โ”œโ”€โ”€ translations_fr.json
โ””โ”€โ”€ ...
localize.runtime.json
```
---
### Step 3: Wrap your app
```tsx
import { LanguageContextProvider } from "localize-ai";
<LanguageContextProvider>
<App />
</LanguageContextProvider>
```
---
### Step 4: Use translations
```tsx
import { useTranslation } from "localize-ai";
function App() {
const { t } = useTranslation();
return <h1>{t("Hello world")}</h1>;
}
```
---
## ๐ŸŒ Change language
```tsx
const { setLang } = useTranslation();
setLang("fr"); // switch language
```
---
## ๐Ÿง  How it works
```text
Code โ†’ Extract โ†’ Clean โ†’ AI Translate โ†’ JSON โ†’ React Context โ†’ UI
```
* Only new strings are translated
* Only missing languages are generated
* Existing translations are reused
---
## ๐Ÿ“ Output
```bash
public/
โ”œโ”€โ”€ translations_en.json
โ”œโ”€โ”€ translations_hi.json
โ”œโ”€โ”€ translations_fr.json
โ””โ”€โ”€ ...
```
---
## โšก Example
```tsx
<h1>{t("Get started")}</h1>
```
โžก๏ธ Automatically becomes:
```json
{
"Get started": {
"en": "Get started",
"hi": "เคถเฅเคฐเฅ‚ เค•เคฐเฅ‡เค‚",
"fr": "Commencer"
}
}
```
---
## ๐Ÿ›  CLI Commands
```bash
npx localize-ai init # generate runtime config
npx localize-ai translate # extract + translate
```
---
## ๐ŸŽฏ Why localize-ai?
| Feature | localize-ai | traditional i18n |
| ------------------- | ----------- | ---------------- |
| Auto extraction | โœ… | โŒ |
| AI translation | โœ… | โŒ |
| Incremental updates | โœ… | โŒ |
| Setup time | โšก minutes | โณ hours |
---
## โš ๏ธ Notes
* Only static strings inside `t("...")` are extracted
* Ensure `public/` folder exists
* API key is required only for translation step
---
## ๐Ÿ—บ Roadmap
### Core Improvements
* [ ] AST-based extraction (no regex)
* [ ] Better error handling & retry logic for failed translations
* [ ] CLI UX improvements (spinners, better logs)
### Performance & DX
* [x] Lazy loading translations
* [x] Per-locale splitting
* [x] Built-in caching
* [ ] CDN support for translation files
### Features
* [x] Multi-provider support (OpenAI, Gemini)
* [ ] Fallback providers (auto-switch if one fails)
* [ ] Custom translation rules (skip/override specific keys)
* [ ] Namespace support (group translations)
### Developer Experience
* [ ] VS Code extension (highlight untranslated strings)
* [ ] Debug mode (show missing translations in UI)
* [ ] CLI dry-run mode
### Future Ideas
* [ ] Support for frameworks beyond React (Next.js, Vue)
* [ ] Dashboard for managing translations
* [ ] Analytics (missing keys, usage tracking)
---
## ๐Ÿค Contributing
PRs welcome! Feel free to open issues or suggest improvements.
---
## ๐Ÿ“„ License
MIT
---
## ๐Ÿ’ฌ Author
**Parth Gupta**
---
## โญ Support
If you like this project:
๐Ÿ‘‰ Star the repo
๐Ÿ‘‰ Share with developers
๐Ÿ‘‰ Give feedback
---