PHPackages                             elegantly/laravel-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. elegantly/laravel-translator

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

elegantly/laravel-translator
============================

All on one translations management for Laravel

v4.0.4(3w ago)6333.1k↑128.8%4[1 PRs](https://github.com/ElegantEngineeringTech/laravel-translator/pulls)MITPHPPHP ^8.2CI passing

Since Jun 19Pushed 1w ago1 watchersCompare

[ Source](https://github.com/ElegantEngineeringTech/laravel-translator)[ Packagist](https://packagist.org/packages/elegantly/laravel-translator)[ Docs](https://github.com/ElegantEngineeringTech/laravel-translator)[ GitHub Sponsors](https://github.com/ElegantEngineeringTech)[ RSS](/packages/elegantly-laravel-translator/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (85)Versions (104)Used By (0)

All-in-One Translations Manager for Laravel
===========================================

[](#all-in-one-translations-manager-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/82d2067d570cb78b2aee79fbd3af77c776cf7a1963632646809221f6a882721a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c6567616e746c792f6c61726176656c2d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elegantly/laravel-translator)[![GitHub Tests Action Status](https://camo.githubusercontent.com/4df4b423d62c5ab535d71530c9d1786ac821424cff29aac8fc720254bb04c2c7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f456c6567616e74456e67696e656572696e67546563682f6c61726176656c2d7472616e736c61746f722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/ElegantEngineeringTech/laravel-translator/actions?query=workflow%3Arun-tests+branch%3Amain)[![Laravel Pint](https://camo.githubusercontent.com/c839a6b49b85cbeeaa6365d77225ed741404c5e42101ed3c6b46b1a1edf9d558/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f456c6567616e74456e67696e656572696e67546563682f6c61726176656c2d7472616e736c61746f722f70696e742e796d6c3f6c6162656c3d6c61726176656c25323070696e74267374796c653d666c61742d737175617265)](https://github.com/ElegantEngineeringTech/laravel-translator/actions?query=workflow%3Apint)[![Total Downloads](https://camo.githubusercontent.com/a77abeeb30c121603de1b12f6c707792e5a3c861d5a592deb6fba45e4612de19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c6567616e746c792f6c61726176656c2d7472616e736c61746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elegantly/laravel-translator)

[![Laravel Translator](https://repository-images.githubusercontent.com/816339762/eefcad09-87ad-484e-bcc4-5759303dc4b6)](https://repository-images.githubusercontent.com/816339762/eefcad09-87ad-484e-bcc4-5759303dc4b6)

Easily manage all your Laravel translation strings with powerful features:

- **Translate** strings into other languages using OpenAI, Claude, Gemini or custom services.
- **Proofread** translations to fix grammar and syntax automatically (using OpenAI, Claude, Gemini or custom service).
- **Find missing** translation strings across locales.
- **Detect unused** translation keys in your codebase.
- **Sort** translations in natural order.
- **Import &amp; Export** translations in a CSV file.

---

Try Laratranslate – A Powerful UI for Managing Translations
-----------------------------------------------------------

[](#try-laratranslate--a-powerful-ui-for-managing-translations)

[![Laratranslate](https://camo.githubusercontent.com/62ba6aa4683d7ab448e984775c89b0e03ce6f89e5cec5c9129d980c213eede6c/68747470733a2f2f656c6567616e746c792e6465762f6173736574732f6c6172617472616e736c6174652f6f70656e67726170682e6a7067)](https://elegantly.dev/laratranslate/)

---

Table of Contents
=================

[](#table-of-contents)

1. [How does it work?](#how-does-it-work)
2. [Installation](#installation)
3. [Configuring the Driver](#configuring-the-driver)
4. [Configuring the Locales](#configuring-the-locales)
    - [Automatic Detection](#automatic-detection)
    - [Manual Setup](#manual-setup)
5. [Configuring the Code Scanner](#configuring-the-code-scanner)
    - [Requirements](#requirements)
    - [Included Paths](#included-paths)
    - [Excluded Paths](#excluded-paths)
    - [Ignored Translation Keys](#ignored-translation-keys)
6. [Sorting and Formatting](#sorting-and-formatting)
    - [CLI Commands](#cli-commands)
    - [Using Code](#using-code)
7. [Automatic Translation](#automatic-translation)
    - [Configuring the Laravel AI SDK](#configuring-the-laravel-ai-sdk)
    - [CLI Translation](#cli-translation)
    - [Programmatic Translation](#programmatic-translation)
8. [Proofreading Translations](#proofreading-translations)
    - [CLI Proofreading](#cli-proofreading)
    - [Programmatic Proofreading](#programmatic-proofreading)
9. [Identifying Untranslated Translations](#identifying-untranslated-translations)
    - [CLI Usage](#cli-usage)
    - [Programmatic Usage](#programmatic-usage)
10. [Detecting Missing Translations](#detecting-missing-translations)
    - [CLI Usage](#cli-usage-1)
    - [Programmatic Usage](#programmatic-usage-1)
11. [Detecting Dead Translations](#detecting-dead-translations)
    - [CLI Usage](#cli-usage-2)
    - [Programmatic Usage](#programmatic-usage-2)
12. [Export to a CSV](#export-to-a-csv)
    - [CLI Usage](#cli-usage-3)
    - [Programmatic Usage](#programmatic-usage-3)
13. [Import from a CSV](#import-from-a-csv)
    - [CLI Usage](#cli-usage-4)
    - [Programmatic Usage](#programmatic-usage-4)

How does it work?
-----------------

[](#how-does-it-work)

This package will directly modify your translation files like `/lang/en/messages.php` or `/lang/fr.json` for example.

Both `PHP` and `JSON` files are supported.

Advanced features like dead translations detection will scan your entire codebase to find unused translation strings.

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

[](#installation)

Install the package via Composer:

```
composer require elegantly/laravel-translator --dev
```

Add the following line to your `.gitignore` file:

```
storage/.translator.cache

```

Publish the configuration file:

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

---

Configuring the Driver
----------------------

[](#configuring-the-driver)

This package uses a driver-based architecture. By default, it supports two standard drivers: PHP and JSON.

- Use the `PHP` driver if you store your translation strings in `.php` files, such as `/lang/en/message.php`.
- Use the `JSON` driver if you store your translation strings in `.json` files, such as `/lang/fr.json`.

You can also create custom drivers for alternative storage methods, such as a database.

Set the default driver in the configuration file:

```
use Elegantly\Translator\Drivers\PhpDriver;

return [
    /**
     * Possible values: 'php', 'json', or a class-string implementing Driver.
     */
    'driver' => PhpDriver::class,

    // ...
];
```

Note

All features are supported in both the PHP and JSON drivers.

Configuring the Locales
-----------------------

[](#configuring-the-locales)

### Automatic Detection

[](#automatic-detection)

By default, this package will attempt to determine the locales defined in your application by scanning your `lang` directory.

You can customize this behavior in the configuration file.

```
use Elegantly\Translator\Support\LocaleValidator;

return [
    // ...
    'locales' => LocaleValidator::class,
    // ...
];
```

### Manual Setup

[](#manual-setup)

To set the locales manually, use the following configuration:

```
return [
    // ...
    'locales' => ['en', 'fr', 'es'],
    // ...
];
```

---

Configuring the Code Scanner
----------------------------

[](#configuring-the-code-scanner)

Service: `searchcode`.

Features:

- [Detecting Missing Translations](#detecting-missing-translations)
- [Detecting Dead Translations](#detecting-dead-translations)

Both the detection of dead and missing translations rely on scanning your code.

- **Missing translations** are keys found in your codebase but missing in translation files.
- **Dead translations** are keys defined in your translation files but unused in your codebase.

### Requirements

[](#requirements)

At the moment, this package can only scan the following files:

- `.php`
- `.blade.php`

Note

If you use a React or Vue frontend, it would not be able to scan those files, making this feature irrelevant.

The default detector uses `nikic/php-parser` to scan all your `.php` files, including the Blade ones.

In order to be able to detect your keys, you will have to use one of the following Laravel function:

- `__(...)`,
- `trans(...)`
- `trans_choice(...)`
- `\Illuminate\Support\Facades\Lang::get(...)`
- `\Illuminate\Support\Facades\Lang::has(...)`
- `\Illuminate\Support\Facades\Lang::hasForLocale(...)`
- `\Illuminate\Support\Facades\Lang::choice(...)`
- `app('translator')->get(...)`
- `app('translator')->has(...)`
- `app('translator')->hasForLocale(...)`
- `app('translator')->choice(...)`

Or one of the following Laravel Blade directive:

- `@lang(...)`

Here is some example of do's and don'ts:

```
__('messages.home.title'); // ✅ 'messages.home.title' is detected

foreach(__('messages.welcome.lines') as $line){
    // ✅ 'messages.welcome.lines' and all of its children are detected.
}

$key = 'messages.home.title';
__($key); // ❌ no key is detected
```

### Included Paths

[](#included-paths)

Specify paths to scan for translation keys. By default, both `.php` and `.blade.php` files are supported.

```
return [
    'searchcode' => [
        'paths' => [
            app_path(),
            resource_path(),
        ],
    ],
];
```

### Excluded Paths

[](#excluded-paths)

Exclude irrelevant paths for optimized scanning, such as test files or unrelated directories.

```
return [
    'searchcode' => [
        'excluded_paths' => [
            'tests'
        ],
    ],
];
```

### Ignored Translation Keys

[](#ignored-translation-keys)

Ignore specific translation keys:

```
return [
    'searchcode' => [
        'ignored_translations' => [
            'countries', // Ignore keys starting with 'countries'.
        ],
    ],
];
```

---

Sorting and Formatting
----------------------

[](#sorting-and-formatting)

### CLI Commands

[](#cli-commands)

Sort translations with the default driver:

```
php artisan translator:sort
```

Specify a driver for sorting:

```
php artisan translator:sort --driver=json
```

### Using Code

[](#using-code)

Sort translations programmatically with the default driver:

```
use Elegantly\Translator\Facades\Translator;

Translator::sortTranslations(locale: 'fr');
```

Specify a driver:

```
Translator::driver('json')->sortTranslations(locale: 'fr');
```

---

Automatic Translation
---------------------

[](#automatic-translation)

Service: `translate`.

By default, this package uses the Laravel AI SDK (`laravel/ai`) to perform translation requests through an AI provider. See the official documentation for more details: [Laravel AI SDK documentation](https://laravel.com/docs/13.x/ai-sdk)

You can also implement your own translation service if you need custom behavior or provider integration.

### Configuring the Laravel AI SDK

[](#configuring-the-laravel-ai-sdk)

You may override the Laravel AI SDK configuration through the `translator.services.ai` configuration options:

```
return [
    // ...

    'services' => [
        'ai' => [
            'provider' => null,
            'model' => null,
            'timeout' => null,

            // Number of items processed per request.
            'chunk' => 10,

            // Enable concurrent translation requests.
            'concurrency' => false,
        ],
    ],
];
```

The Laravel AI SDK reads provider credentials and default settings from the `config/ai.php` configuration file.

### CLI Translation

[](#cli-translation)

Translate all missing keys from English to every configured locale:

```
php artisan translator:translate en
```

Force re-translation of all keys (overwrites existing values):

```
php artisan translator:translate en --force
```

Translate from English to French:

```
php artisan translator:translate en --target=fr
```

Translate using smaller/larger chunks (defaults to `10`):

```
php artisan translator:translate en --chunk=25
```

Translate using a specific driver:

```
php artisan translator:translate en --driver=json
```

Inspect untranslated keys before translating:

```
php artisan translator:untranslated en fr
```

Inspect untranslated keys with a specific driver:

```
php artisan translator:untranslated en fr --driver=json
```

Add a new locale and immediately translate it from an existing source locale:

```
php artisan translator:add-locale fr en --translate
```

### Programmatic Translation

[](#programmatic-translation)

Translate translations programmatically with the default driver:

```
Translator::translateTranslations(
    source: 'en',
    target: 'fr',
    keys: ['validation.title', ...]
);
```

Specify a driver for translation:

```
Translator::driver('json')->translateTranslations(
    source: 'en',
    target: 'fr',
    keys: ['My Title', ...]
);
```

---

Proofreading Translations
-------------------------

[](#proofreading-translations)

Service: `proofread`.

The proofreading service improves existing translation strings by correcting grammar, spelling, syntax, and wording while preserving the original meaning and translation context.

By default, this package uses the Laravel AI SDK (`laravel/ai`) to send proofreading requests to an AI provider. See the official documentation for more details: [Laravel AI SDK documentation](https://laravel.com/docs/13.x/ai-sdk)

See [Configuring the Laravel AI SDK](#configuring-the-laravel-ai-sdk) for configuration details.

You may also implement a custom proofreading service to integrate a different provider or customize the proofreading workflow.

### CLI Proofreading

[](#cli-proofreading)

Proofread all strings in the target locale (English).

```
php artisan translator:proofread en
```

### Programmatic Proofreading

[](#programmatic-proofreading)

Proofread translations with the default driver:

```
Translator::proofreadTranslations(
    locale: 'fr',
    keys: ['auth.email', ...]
);
```

Specify a driver:

```
Translator::driver('json')->proofreadTranslations(
    locale: 'fr',
    keys: ['My Title', ...]
);
```

---

Identifying Untranslated Translations
-------------------------------------

[](#identifying-untranslated-translations)

Find keys defined in one locale but missing in another.

### CLI Usage

[](#cli-usage)

Display all keys defined in the source locale (English) but not in the target locale (French).

```
php artisan translator:untranslated en fr
```

### Programmatic Usage

[](#programmatic-usage)

```
Translator::getUntranslatedTranslations(source: 'en', target: 'fr');
```

---

Detecting Missing Translations
------------------------------

[](#detecting-missing-translations)

Service: `searchcode`. Configuration: [Configuring the Code Scanner](#configuring-the-code-scanner)

Missing translations are keys found in your codebase but missing in translation files.

### CLI Usage

[](#cli-usage-1)

Find keys defined in your codebase but missing in your locale (English) using your default driver:

```
php artisan translator:missing en
```

Specify a driver:

```
php artisan translator:missing en --driver=json
```

Add the missing keys to your driver:

```
php artisan translator:missing en --sync
```

### Programmatic Usage

[](#programmatic-usage-1)

```
Translator::getMissingTranslations(locale: 'en');
```

---

Detecting Dead Translations
---------------------------

[](#detecting-dead-translations)

Service: `searchcode`. Configuration: [Configuring the Code Scanner](#configuring-the-code-scanner)

Dead translations are keys defined in your locale (English) but unused in your codebase.

### CLI Usage

[](#cli-usage-2)

```
php artisan translator:dead en
```

### Programmatic Usage

[](#programmatic-usage-2)

```
Translator::getDeadTranslations(locale: 'fr');
```

Export to a CSV
---------------

[](#export-to-a-csv)

Service: `exporter`

Export all your translation strings to a CSV file in the following format:

keyenfrmessages.auth.loginLoginConnexion### CLI Usage

[](#cli-usage-3)

```
php artisan translator:export /path/to/my/file.csv
```

### Programmatic Usage

[](#programmatic-usage-3)

```
$path = Translator::exportTranslations('/path/to/my/file.csv');
```

Import from a CSV
-----------------

[](#import-from-a-csv)

Service: `exporter`

Import translation strings from a CSV file. Ensure your CSV follows the format below:

keyenfrmessages.auth.loginLoginConnexion### CLI Usage

[](#cli-usage-4)

```
php artisan translator:import /path/to/my/file.csv
```

### Programmatic Usage

[](#programmatic-usage-4)

```
$translations = Translator::importTranslations('/path/to/my/file.csv');
```

Testing
-------

[](#testing)

Run tests using:

```
composer test
```

---

Changelog
---------

[](#changelog)

See the [CHANGELOG](CHANGELOG.md) for recent updates.

---

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

[](#contributing)

Check the [CONTRIBUTING](CONTRIBUTING.md) guide for details.

---

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Report security vulnerabilities via GitHub or email.

---

Credits
-------

[](#credits)

- [Quentin Gabriele](https://github.com/QuentinGab)
- [All Contributors](../../contributors)

---

License
-------

[](#license)

This package is licensed under the MIT License. See the [License File](LICENSE.md) for more details.

###  Health Score

61

—

FairBetter than 98% of packages

Maintenance97

Actively maintained with recent releases

Popularity43

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 87.2% of commits — single point of failure

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 ~7 days

Total

96

Last Release

24d ago

Major Versions

v0.1.3 → v1.0.02024-08-17

v1.1.8 → v2.0.02024-11-17

v2.5.3 → v3.0.02025-05-28

v3.6.3 → v4.0.02026-05-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/d769563728757858e249f266ac2555f28db5640124df92821ed17d93ee76fc7b?d=identicon)[QuentinGab](/maintainers/QuentinGab)

---

Top Contributors

[![QuentinGab](https://avatars.githubusercontent.com/u/40128136?v=4)](https://github.com/QuentinGab "QuentinGab (252 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (17 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (11 commits)")[![sajjadhossainshohag](https://avatars.githubusercontent.com/u/63788037?v=4)](https://github.com/sajjadhossainshohag "sajjadhossainshohag (6 commits)")[![pablo-gonzalez-helpwan](https://avatars.githubusercontent.com/u/175231585?v=4)](https://github.com/pablo-gonzalez-helpwan "pablo-gonzalez-helpwan (1 commits)")[![munezaclovis](https://avatars.githubusercontent.com/u/51137458?v=4)](https://github.com/munezaclovis "munezaclovis (1 commits)")[![yeasherarafath](https://avatars.githubusercontent.com/u/50262277?v=4)](https://github.com/yeasherarafath "yeasherarafath (1 commits)")

---

Tags

laravellaravel-translationlaravel-translation-managerlocalizationlocalization-toolphptranslation-managementtranslationslaravellaravel-translationsElegantlylaravel-translatorElegantEngineering

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[nativephp/desktop

NativePHP for Desktop

39742.4k8](/packages/nativephp-desktop)

PHPackages © 2026

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