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

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

eii/laravel-ai-locale-generator
===============================

AI powered localization generator for Laravel

00PHP

Since Mar 27Pushed 3mo agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel AI Locale Generator
===========================

[](#laravel-ai-locale-generator)

AI-powered localization generator for Laravel applications.
Automatically extracts texts from Blade files, generates locale keys, optionally translates to multiple languages, and safely updates your Blade files.

---

Features
--------

[](#features)

- Extract texts from Blade files and generate locale keys
- AI-assisted key generation (OpenAI)
- Translation support (Google Translate &amp; DeepL)
- Multi-language locale PHP files (`resources/lang/en/*.php`, `ja`, `es`, etc.)
- Safe Blade rewriting with optional backup
- Dot notation support (`welcome`, `auth.login`) for Blade files
- Fully configurable via `config/ai-locale-generator.php`
- CLI commands for automated workflows

---

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

[](#installation)

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

Publish the config file:

```
php artisan vendor:publish --tag=ai-locale-generator-config
```

Update your .env with API keys:

```
OPENAI_API_KEY=sk-xxx
GOOGLE_TRANSLATE_API_KEY=xxx
DEEPL_API_KEY=xxx
```

---

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

[](#configuration)

`config/ai-locale-generator.php`:

```
return [
    'provider' => 'openai',
    'api_key' => env('OPENAI_API_KEY'),
    'model' => 'gpt-4o-mini',

    'translator' => 'google', // options: 'google', 'deepl'
    'google_api_key' => env('GOOGLE_TRANSLATE_API_KEY'),
    'deepl_api_key' => env('DEEPL_API_KEY'),

    'backup' => true, // default: backup Blade files before applying
];
```

---

Commands
--------

[](#commands)

### 1. Generate Locale Files

[](#1-generate-locale-files)

```
php artisan locale:generate  [--lang=ja,es]
```

- Extracts texts from the Blade file
- Creates source language file `resources/lang/en/.php` automatically
- Translates to languages specified in `--lang` (optional)
- Example:

```
php artisan locale:generate welcome --lang=ja,es
```

---

### 2. Apply Keys to Blade

[](#2-apply-keys-to-blade)

```
php artisan locale:apply  [--backup|--no-backup]
```

- Replaces original texts with locale keys
- Uses `APP_LOCALE` as source language
- Optional backup (`.bak`) before rewriting
- Example:

```
php artisan locale:apply welcome auth.login --backup
```

---

Usage Notes
-----------

[](#usage-notes)

- Source language is always your `APP_LOCALE` (`.env`).
- Translation languages are optional.
- Currently does not handle dynamic variables in texts (e.g., `:count`). Planned for future release.
- Supports both single and double-quoted Blade translations.

---

Example Workflow
----------------

[](#example-workflow)

1. Generate keys &amp; translations:

```
php artisan locale:generate welcome --lang=ja,es
```

2. Manually edit translations if needed:

```
// resources/lang/ja/welcome.php
'welcome_message' => 'ようこそ',
```

3. Apply keys to Blade:

```
php artisan locale:apply welcome
```

4. Now your Blade file uses:

```
{{ __('welcome.welcome_message') }}
```

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

[](#requirements)

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

License
-------

[](#license)

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

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance55

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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.

### 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 (2 commits)")

### Embed Badge

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

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

###  Alternatives

[php-translation/translator

Translator services

25224.8k5](/packages/php-translation-translator)[smmoosavi/php-gettext

Wrapper for php-gettext by danilo segan. This library provides PHP functions to read MO files even when gettext is not compiled in or when appropriate locale is not present on the system.

1926.6k1](/packages/smmoosavi-php-gettext)[laradevs/spanish

labels translated to spanish

166.7k](/packages/laradevs-spanish)

PHPackages © 2026

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