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

v3.5.0(2mo ago)6216.9k↓25.7%3[2 PRs](https://github.com/ElegantEngineeringTech/laravel-translator/pulls)MITPHPPHP ^8.2CI passing

Since Jun 19Pushed 1mo 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 1mo ago

READMEChangelog (10)Dependencies (34)Versions (93)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)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/c82728898380fc8524addcb8c35e30261d418738ee23b8d7f290c5deb3d14b80/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f456c6567616e74456e67696e656572696e67546563682f6c61726176656c2d7472616e736c61746f722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/ElegantEngineeringTech/laravel-translator/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![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 Prism](#configuring-prism)
    - [Using Claude](#using-claude)
    - [Using Gemini](#using-gemini)
    - [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`.

Before translating, configure a translation service. The package supports:

- **Prism (prism-php/prism)**
- Any Prism provider (OpenAI, Anthropic/Claude, Gemini, Ollama, ...)

Custom translation services can also be implemented.

### Configuring Prism

[](#configuring-prism)

Enable Prism as your translation service in `config/translator.php`:

```
return [
    // ...

    'translate' => [
        'service' => 'prism',
        // ...
    ],
];
```

Choose the provider/model used by the translator:

```
return [
    // ...

    'services' => [
        'prism' => [
            'provider' => env('TRANSLATOR_PRISM_PROVIDER', 'openai'),
            'model' => env('TRANSLATOR_PRISM_MODEL', 'gpt-4.1-mini'),
        ],
    ],

    // ...
];
```

Prism itself reads provider credentials from `config/prism.php`.

If you haven't published the Prism config yet:

```
php artisan vendor:publish --tag=prism-config
```

### Using Claude

[](#using-claude)

To translate with Claude via Prism, set the provider to `anthropic` and pick a Claude model:

```
return [
    // ...

    'services' => [
        'prism' => [
            'provider' => 'anthropic',
            'model' => 'claude-3-7-sonnet-latest',
        ],
    ],

    // ...
];
```

> 💡 **Note:** Ensure your `ANTHROPIC_API_KEY` is configured in `config/prism.php` (or set in your `.env`).

### Using Gemini

[](#using-gemini)

To translate with Gemini via Prism, set the provider to `gemini` and pick a Gemini model:

```
return [
    // ...

    'services' => [
        'prism' => [
            'provider' => 'gemini',
            'model' => 'gemini-2.0-flash',
        ],
    ],
];
```

> 💡 **Note:** Ensure your `GEMINI_API_KEY` is configured in `config/prism.php` (or set in your `.env`).

### CLI Translation

[](#cli-translation)

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

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

Specify a driver:

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

Add a new locale (French) with their translations from a source (English):

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

Translate all keys from a source locale (English) into a target locale (French). By default, it only translates missing keys:

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

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

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

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

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

Translate using a specific driver:

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

### 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`.

Proofreading corrects the grammar and syntax of your translation strings.

This package ships with a Prism-based proofreading service (`prism-php/prism`), and custom services can also be implemented.

Enable it by setting `translator.proofread.service` to `prism`, and configure Prism as described in [Configuring Prism](#configuring-prism).

### 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

57

—

FairBetter than 98% of packages

Maintenance87

Actively maintained with recent releases

Popularity40

Moderate usage in the ecosystem

Community15

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 88.7% 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

87

Last Release

76d 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

### 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 (235 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (13 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (9 commits)")[![sajjadhossainshohag](https://avatars.githubusercontent.com/u/63788037?v=4)](https://github.com/sajjadhossainshohag "sajjadhossainshohag (6 commits)")[![munezaclovis](https://avatars.githubusercontent.com/u/51137458?v=4)](https://github.com/munezaclovis "munezaclovis (1 commits)")[![pablo-gonzalez-helpwan](https://avatars.githubusercontent.com/u/175231585?v=4)](https://github.com/pablo-gonzalez-helpwan "pablo-gonzalez-helpwan (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

[worksome/envy

Automatically keep your .env files in sync.

6871.8M](/packages/worksome-envy)[askdkc/breezejp

Laravel Starter Kit (Livewire+Breeze+Laravel UI+Jetstream)や標準のバリデーションメッセージを全て一瞬で日本語化し、言語切替機能も提供するパッケージです / This package provides all-in-one Japanese translation for Laravel StarterKit (Livewire StarterKit, Breeze, Laravel UI and Jetstream) packages and validation messages with language switching feature.

590244.8k1](/packages/askdkc-breezejp)[outhebox/laravel-translations

Manage your Laravel translations with a beautiful UI. Add, edit, delete, import, and export translations with ease.

80687.6k](/packages/outhebox-laravel-translations)[statikbe/laravel-filament-chained-translation-manager

A translation manager tool for Laravel Filament, that makes use of the Laravel Chained Translator.

92108.7k](/packages/statikbe-laravel-filament-chained-translation-manager)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[elegantly/laravel-invoices

Store invoices safely in your Laravel application

23131.8k](/packages/elegantly-laravel-invoices)

PHPackages © 2026

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