PHPackages                             samuelgjekic/laravel-ai-translator - 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. [Localization &amp; i18n](/categories/localization)
4. /
5. samuelgjekic/laravel-ai-translator

ActiveLibrary[Localization &amp; i18n](/categories/localization)

samuelgjekic/laravel-ai-translator
==================================

AI-powered translation package for Laravel applications using Prism AI

v1.0.5(6mo ago)13MITPHPPHP ^8.2

Since Dec 20Pushed 6mo agoCompare

[ Source](https://github.com/samuelgjekic/laravel-ai-translator)[ Packagist](https://packagist.org/packages/samuelgjekic/laravel-ai-translator)[ RSS](/packages/samuelgjekic-laravel-ai-translator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (6)Versions (7)Used By (0)

Laravel AI Translator
=====================

[](#laravel-ai-translator)

Laravel AI Translator is a developer tool for **scanning** and **generating** translations in Laravel using AI.

Right now it focuses on **JSON translations** (e.g. `lang/en.json`) and exports/imports that workflow.

[![image](https://private-user-images.githubusercontent.com/41647182/528878908-620167fe-f0d8-4f5c-b18a-f31a2da4f89d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3ODA1NTYxMDYsIm5iZiI6MTc4MDU1NTgwNiwicGF0aCI6Ii80MTY0NzE4Mi81Mjg4Nzg5MDgtNjIwMTY3ZmUtZjBkOC00ZjVjLWIxOGEtZjMxYTJkYTRmODlkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNjA2MDQlMkZ1cy1lYXN0LTElMkZzMyUyRmF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1QrT0ApoPfTI3Gh-cNyk9JAtFA3VEXM2k2K5A)What it does
------------

[](#what-it-does)

### 1) Translate a JSON language file with AI

[](#1-translate-a-json-language-file-with-ai)

If you have a lot of keys (e.g. 3000+), you can translate them into a new language using a single Artisan command.

Example: translate `en.json` → Swedish:

```
php artisan translate:language swedish
```

Under the hood the package:

- reads your source JSON (default is configurable)
- splits it into chunks
- securely translates a few keys at a time
- writes the final translated JSON file (e.g. `sv.json`)

### 2) Scan your app/views and generate a JSON file of translation keys

[](#2-scan-your-appviews-and-generate-a-json-file-of-translation-keys)

If you *don’t* already have a JSON file with all your keys, you can generate one by scanning your codebase:

```
php artisan translations:export
```

You can also override the output location:

```
php artisan translations:export --output=path/to/export.json
```

The scanner looks through your configured paths (app + views by default) and extracts translation keys from:

- `__('...')`, `@lang('...')`, `trans('...')`, `Lang::get('...')`
- keys with parameters like `__('Items total: :count', ['count' => ...])`
- placeholders/variables like `:count`, `{count}`, `{{name}}`, etc.

> Variables/placeholders are preserved by the AI translator and should not be translated.

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

[](#installation)

```
composer require samuelgjekic/laravel-ai-translator
```

Publish config (recommended):

```
php artisan vendor:publish --tag=ai-translator-config
```

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

[](#configuration)

### AI credentials (Prism)

[](#ai-credentials-prism)

This package uses **Prism** under the hood. Set your provider keys the way Prism expects.

Example for OpenAI:

```
OPENAI_API_KEY=your-api-key
```

### Provider + model

[](#provider--model)

You can switch provider/model via env:

```
AI_TRANSLATOR_PROVIDER=openai
AI_TRANSLATOR_MODEL=gpt-5-mini
```

### Package config

[](#package-config)

After publishing `config/ai-translator.php`, you can configure:

- default `source_language` (e.g. `en`)
- chunk size
- queue/job settings (tries, timeout, delays)
- scanning paths and export path
- regex patterns for key detection

The most important config block is:

```
'paths' => [
    // Directory for translation JSON files. null = use Laravel's default lang_path()
    'translations' => null,

    // Default export file for the scanner (relative to base_path())
    'export' => 'lang/export.json',

    // What to scan when running translations:export
    'scan' => [
        'app',
        'resources/views',
    ],
],
```

Usage
-----

[](#usage)

### Translate language files

[](#translate-language-files)

Translate using queue jobs (recommended):

```
php artisan translate:language swedish
```

Specify a custom source file (without `.json`):

```
php artisan translate:language swedish --source=en
```

Run without jobs (not recommended, but useful for quick testing):

```
php artisan translate:language swedish --sync
```

Translate only a few chunks (useful for testing prompts / rate limiting):

```
php artisan translate:language swedish --chunks=3
```

### Scan &amp; export keys

[](#scan--export-keys)

Scan your app + views (configured in `paths.scan`) and export a key JSON:

```
php artisan translations:export
```

Override output file:

```
php artisan translations:export --output=myfolder/keys.json
```

Notes / current limitations
---------------------------

[](#notes--current-limitations)

- Currently **JSON translations only** (`lang/*.json`).
- The translator has been tested on **5000+ keys**, including keys with variables/placeholders, across multiple languages.
- Translating large files can take time depending on queue throughput, rate limits, and key count.
- More support for other Laravel translation styles (arrays, vendor files, etc.) is coming.

Contributing
------------

[](#contributing)

PRs are welcome.

If you’d like to add more scanning patterns, improve prompts, add support for array-based translations, or add tests—jump in.

License
-------

[](#license)

MIT. See `LICENSE.md`.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance67

Regular maintenance activity

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

5

Last Release

196d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/41647182?v=4)[Samuel Gjekic](/maintainers/samuelgjekic)[@samuelgjekic](https://github.com/samuelgjekic)

---

Top Contributors

[![MrClaudeTechlove](https://avatars.githubusercontent.com/u/255687840?v=4)](https://github.com/MrClaudeTechlove "MrClaudeTechlove (7 commits)")[![samuelattechlove](https://avatars.githubusercontent.com/u/255687840?v=4)](https://github.com/samuelattechlove "samuelattechlove (7 commits)")[![samuelgjekic](https://avatars.githubusercontent.com/u/41647182?v=4)](https://github.com/samuelgjekic "samuelgjekic (2 commits)")

---

Tags

aifilamentlaravelopenaitranslatetranslatestranslationslaravellocalizationi18ntranslationaiprismtolgee

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/samuelgjekic-laravel-ai-translator/health.svg)

```
[![Health](https://phpackages.com/badges/samuelgjekic-laravel-ai-translator/health.svg)](https://phpackages.com/packages/samuelgjekic-laravel-ai-translator)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[laravel/sail

Docker files for running a basic Laravel application.

1.9k205.7M1.3k](/packages/laravel-sail)[laravel/boost

Laravel Boost accelerates AI-assisted development by providing the essential context and structure that AI needs to generate high-quality, Laravel-specific code.

3.5k21.5M594](/packages/laravel-boost)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M151](/packages/laravel-mcp)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

725173.2k14](/packages/tallstackui-tallstackui)

PHPackages © 2026

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