PHPackages                             janakkapadia/insta-translate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. janakkapadia/insta-translate

ActiveLibrary

janakkapadia/insta-translate
============================

0.1.6(yesterday)022↑2627.3%MITPHP ^8.3

Since Jul 19Compare

[ Source](https://github.com/janakkapadia/insta-translate)[ Packagist](https://packagist.org/packages/janakkapadia/insta-translate)[ Docs](https://github.com/janakkapadia/insta-translate)[ GitHub Sponsors](https://github.com/janakkapadia)[ RSS](/packages/janakkapadia-insta-translate/feed)WikiDiscussions Synced today

READMEChangelog (10)Dependencies (9)Versions (13)Used By (0)

InstaTranslate for Laravel
==========================

[](#instatranslate-for-laravel)

A lightweight Laravel package that leverages AI (via `laravel/ai`) to automatically translate language strings for your application. It replaces traditional translation management platforms by using AI to directly sync and translate missing keys in your `lang/` files.

Features
--------

[](#features)

- **Automated Translation**: Diffs your base locale (`en.json`) against target locales and translates only the missing keys.
- **Batched Requests**: Chunks translations to prevent hitting context window limits of AI models.
- **Multiple AI Providers**: Use any provider supported by `laravel/ai` — Anthropic Claude, Google Gemini, OpenAI, and more.
- **Glossary Protection**: Define brand names, technical terms, and locale-specific overrides that the AI must respect.
- **Context-Aware**: Pass domain context (e.g., "SaaS billing dashboard") so the AI produces more accurate translations.
- **PHP Array Files**: Translate both JSON (`lang/en.json`) and PHP array (`lang/en/auth.php`) translation files.
- **Stale Key Pruning**: Automatically detect and remove translation keys that no longer exist in your base language.
- **Multiple Variations**: Generate 3 translation options per key and interactively choose the best one.
- **Forced Full Translation**: Option to re-translate all keys entirely.

Installation
------------

[](#installation)

This package is installed locally via a path repository. It is already registered in `composer.json` under:

```
"repositories": [
    {
        "type": "path",
        "url": "packages/*"
    }
]
```

Configuration
-------------

[](#configuration)

Add the following environment variables to your `.env` file to configure InstaTranslate:

```
# Set the default model (e.g., claude-3-5-sonnet-20241022, gemini-1.5-pro)
# "claude" and "gemini" are also accepted as shorthands for default models.
INSTA_TRANSLATE_MODEL=claude

# Path to your language files (defaults to the laravel lang directory)
INSTA_TRANSLATE_LANG_PATH=./lang

# The base language to translate from (defaults to "en")
INSTA_TRANSLATE_DEFAULT_LANGUAGE=en

# Add your API Keys (managed automatically by Laravel AI SDK)
ANTHROPIC_API_KEY=your_anthropic_api_key_here
GEMINI_API_KEY=your_google_gemini_api_key_here
```

You can optionally publish the configuration file to customize the default model behavior:

```
php artisan vendor:publish --tag="insta-translate-config"
```

Usage
-----

[](#usage)

### Generating Translations

[](#generating-translations)

```
php artisan translation:generate
```

#### Options

[](#options)

OptionDescriptionExample`--batch=`Number of keys per API request. Defaults to `50`.`--batch=100``--model=`Override the default model. Accepts shorthand (`claude`, `gemini`) or exact versions.`--model=gemini-1.5-pro``--lang=`Target a single locale, creating it if it doesn't exist.`--lang=nl``--key=`Translate specific key(s). Can be used multiple times.`--key="Welcome" --key="Goodbye"``--multiple`Generate 3 translation variations per key and choose interactively.`--key="foo" --multiple``--all`Re-translate **all** keys, overwriting existing translations.`--all``--context=`Provide domain context for more accurate translations.`--context="SaaS billing dashboard"``--php`Process PHP array files (`lang/en/*.php`) instead of JSON.`--php`### Pruning Stale Keys

[](#pruning-stale-keys)

Remove translation keys from target locales that no longer exist in the base language file:

```
# Preview what would be removed (safe)
php artisan translation:prune --dry-run

# Actually remove stale keys
php artisan translation:prune

# Prune a specific locale
php artisan translation:prune --lang=fr

# Prune PHP array files
php artisan translation:prune --php --dry-run
```

Glossary
--------

[](#glossary)

Create a `glossary.json` file in your `lang/` directory to protect brand names and define locale-specific translations:

```
{
  "never_translate": ["InstaRequest", "Laravel", "Stripe", "API"],
  "specific_translations": {
    "Dashboard": {
      "hi": "डैशबोर्ड",
      "fr": "Tableau de bord"
    }
  }
}
```

- **`never_translate`**: Terms that must remain exactly as-is in every language (brand names, technical terms).
- **`specific_translations`**: Per-locale overrides for specific terms. These are injected into the AI prompt and also applied as post-processing replacements.

The glossary path defaults to `lang/glossary.json` and can be overridden via:

```
INSTA_TRANSLATE_GLOSSARY_PATH=./lang/glossary.json
```

Dashboard Web UI
----------------

[](#dashboard-web-ui)

InstaTranslate includes a beautiful, interactive web dashboard where you can visually inspect missing translations, run AI translations in the browser, and review them before saving.

1. Ensure the package service provider is registered (this is automatic in Laravel 11+).
2. Visit `/insta-translate` in your browser (e.g. `https://your-app.test/insta-translate`).

If you have custom domains configured in your application (like a wildcard `Route::domain()` catch-all), you may need to explicitly configure the dashboard's domain in your environment or published config file:

```
# In your .env file
INSTA_TRANSLATE_DOMAIN=your-app.test
```

### Dashboard Configuration Options

[](#dashboard-configuration-options)

You can customize the dashboard route and domain by publishing the config file:

```
php artisan vendor:publish --tag="insta-translate-config"
```

Then in `config/insta-translate.php`:

```
'domain' => env('INSTA_TRANSLATE_DOMAIN', null),
'path' => env('INSTA_TRANSLATE_PATH', 'insta-translate'),
'middleware' => env('INSTA_TRANSLATE_MIDDLEWARE', ['web']),
```

How It Works
------------

[](#how-it-works)

1. The command or dashboard reads the base language file (e.g., `en.json` or `en/*.php`).
2. It iterates over all target locale files.
3. For each locale, it identifies keys that exist in the base file but are missing in the target (unless `--all` is passed).
4. Glossary terms and context are injected into the AI prompt.
5. Missing keys are batched and sent to the AI model via `laravel/ai`.
6. Glossary overrides are applied to the AI response.
7. Translations are merged, sorted alphabetically, and saved.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance100

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

12

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/46623980?v=4)[Janak Kapadia](/maintainers/janakkapadia)[@janakkapadia](https://github.com/janakkapadia)

---

Tags

laraveljanakkapadiainsta-translate

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/janakkapadia-insta-translate/health.svg)

```
[![Health](https://phpackages.com/badges/janakkapadia-insta-translate/health.svg)](https://phpackages.com/packages/janakkapadia-insta-translate)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
