PHPackages                             eii/locale-generator - 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. [Templating &amp; Views](/categories/templating)
4. /
5. eii/locale-generator

ActiveLibrary[Templating &amp; Views](/categories/templating)

eii/locale-generator
====================

A Laravel CLI to extract and translate Blade file strings to JSON language files

1.3.0(2mo ago)4199MITPHPPHP ^8.1

Since Aug 7Pushed 2mo agoCompare

[ Source](https://github.com/amit-eiitech/locale-generator)[ Packagist](https://packagist.org/packages/eii/locale-generator)[ RSS](/packages/eii-locale-generator/feed)WikiDiscussions main Synced today

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

Locale Generator
================

[](#locale-generator)

[![Laravel Installer](https://camo.githubusercontent.com/34c04dd24eb5ccf7762b50446c576c05b7389dd68818a9164e58083567af7a54/68747470733a2f2f65696974656368736f6c7574696f6e732e636f6d2f73746f726167652f7061636b616765732f6c6f63616c652d67656e657261746f722f62616e6e65722e77656270)](https://camo.githubusercontent.com/34c04dd24eb5ccf7762b50446c576c05b7389dd68818a9164e58083567af7a54/68747470733a2f2f65696974656368736f6c7574696f6e732e636f6d2f73746f726167652f7061636b616765732f6c6f63616c652d67656e657261746f722f62616e6e65722e77656270)

**Locale Generator** is a Laravel Artisan command that simplifies multilingual development by automatically extracting translation strings (`__()`, `trans()`, `@lang()`, `trans_choice()`) from Blade templates and generating JSON language files.
It optionally integrates with **Google Cloud Translate** or **DeepL** to provide instant translations, helping you speed up localization workflows.

---

Changelog
---------

[](#changelog)

Please see [CHANGELOG.md](CHANGELOG.md) for more information on what has changed recently.

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

[](#installation)

```
composer require eii/locale-generator
```

Setup
-----

[](#setup)

1. **Publish Configuration**:

    ```
    php artisan vendor:publish --tag=config
    ```
2. **Configure Translation Providers**:

    - **Google Cloud Translate**:
        - **Option A (V2 Basic - Recommended)**:
            - Obtain a simple Google Translate API Key. No extra SDK installation is required!
            - Add to `.env`: ```
                GOOGLE_TRANSLATE_API_KEY=your-api-key
                ```
        - **Option B (V3 Advanced)**:
            - Install the SDK: `composer require google/cloud-translate`
            - Create a Google Cloud service account and download the JSON key file.
            - Place the key file in `storage/app/google-credentials.json` or update the path in `config/locale-generator.php`.
            - **Note:** Ensure you do NOT commit this file to version control. Add `google-credentials.json` to your project's `.gitignore` file.
            - Add to `.env`: ```
                GOOGLE_TRANSLATE_KEY_FILE=/path/to/google-credentials.json
                GOOGLE_PROJECT_ID=your-project-id
                ```
    - **DeepL**:
        - Obtain a DeepL API key (free tier available).
        - Add to `.env`: ```
            DEEPL_API_KEY=your-deepl-api-key
            ```

Usage
-----

[](#usage)

Run the lang:extract command:

```
php artisan lang:extract welcome --locales=ja,es,de --translate=google
php artisan lang:extract mail.notification --locales=fr,es --translate=deepl
```

- `file`: Blade file name (e.g., `welcome`, `mail.notification`).
- `--locales`: Comma-separated list of target locales (e.g., `ja,es,de`).
- `--translate`: Translation provider (`google` or `deepl`).
- `--dry-run`: Show what would be extracted and translated without saving to files (useful for CI or review workflows).
- `--cleanup`: Remove obsolete translation keys from JSON files that are no longer found in any of your Blade views.

### Cleanup Example

[](#cleanup-example)

Over time, your translation files may collect obsolete strings that were deleted from your Blade files. The script will automatically warn you if it detects unused translations. To safely remove them:

```
php artisan lang:extract welcome --locales=fr --cleanup
```

### Dry Run Example

[](#dry-run-example)

If you want to preview the extraction and translation without modifying any JSON files, use the `--dry-run` flag:

```
php artisan lang:extract welcome --locales=fr --dry-run
```

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

[](#configuration)

Edit `config/locale-generator.php` to customize:

- `views_path`: Directory for Blade files (default: `resources/views`).
- `google_translate.key_file`: Path to Google Cloud service account JSON key.
- `google_translate.project_id`: Google Cloud project ID.
- `deepl_api_key`: DeepL API key.
- `api_limit.chunk_size`: Number of strings to send in a single API request (default: 20).
- `api_limit.sleep_duration`: Seconds to wait between chunked API requests to prevent rate limiting (default: 1).

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 9.0, 10.0, 11.0, 12.0
- Google Cloud Translate API (for `google` provider)
- DeepL API (for `deepl` provider)

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance88

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~67 days

Total

5

Last Release

62d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/156731306?v=4)[Amit Haldar](/maintainers/amit-eiitech)[@amit-eiitech](https://github.com/amit-eiitech)

---

Top Contributors

[![amit-eiitech](https://avatars.githubusercontent.com/u/156731306?v=4)](https://github.com/amit-eiitech "amit-eiitech (7 commits)")

---

Tags

jsonlaravellocalizationi18ntranslationgeneratorbladelocale

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/eii-locale-generator/health.svg)

```
[![Health](https://phpackages.com/badges/eii-locale-generator/health.svg)](https://phpackages.com/packages/eii-locale-generator)
```

###  Alternatives

[laravel-lang/publisher

Localization publisher for your Laravel application

2169.0M51](/packages/laravel-lang-publisher)[laravel-lang/common

Easily connect the necessary language packs to the application

1593.8M34](/packages/laravel-lang-common)[aschmelyun/cleaver

A blazing-fast static site generator using Laravel's Blade templating engine

2981.0k](/packages/aschmelyun-cleaver)[tomatophp/tomato-admin

Tomato Admin Dashboard Build With FilamentPHP Theme for Laravel Splade

578.7k60](/packages/tomatophp-tomato-admin)

PHPackages © 2026

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