PHPackages                             azizdevfull/lang-gen - 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. azizdevfull/lang-gen

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

azizdevfull/lang-gen
====================

Automatic translation generator for Laravel

1.0.3(3mo ago)616↓100%MITPHP

Since Jan 30Pushed 3mo agoCompare

[ Source](https://github.com/azizdevfull/lang-gen)[ Packagist](https://packagist.org/packages/azizdevfull/lang-gen)[ RSS](/packages/azizdevfull-lang-gen/feed)WikiDiscussions main Synced 1mo ago

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

Laravel LangGen 🌍
=================

[](#laravel-langgen-)

[![Latest Version on Packagist](https://camo.githubusercontent.com/9ea55a426222bb027b2efbcb766b68c614fd9577061f21c9f67a06503b7dde04/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617a697a64657666756c6c2f6c616e672d67656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/azizdevfull/lang-gen)[![Total Downloads](https://camo.githubusercontent.com/21e50f95ec63f9b2e4dbcf20b393209d1064cb7a5e36ef3c7793e11c7007061a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617a697a64657666756c6c2f6c616e672d67656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/azizdevfull/lang-gen)[![License](https://camo.githubusercontent.com/cc31a8263502cd41dd091e4566f7369d5f3d90b7fba8ac720285410a98dbfdf7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f617a697a64657666756c6c2f6c616e672d67656e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/azizdevfull/lang-gen)

**Automatically generate missing translation keys in your Laravel application.**

LangGen scans your application code (`app` and `resources/views`) for translation keys like `__('messages.welcome')` or `@lang('auth.failed')` and automatically creates the corresponding PHP language files.

Unlike other tools, LangGen supports **nested array keys** (dot-notation) and creates clean, native PHP arrays without needing a database.

🚀 Features
----------

[](#-features)

- **Auto-Discovery:** Scans PHP and Blade files for `__(), @lang(), trans()`.
- **JSON Support:** Handles keys with spaces or single strings (e.g., `__('Log in')`) by generating `lang/{code}.json`.
- **Nested Arrays:** Converts `auth.password.min` into `['password' => ['min' => '...']]`.
- **Smart Conflict Handling:** Configurable policy to `preserve` or `overwrite` existing keys.
- **Custom Paths:** Configurable directories to scan (e.g., `Modules`, `routes`).
- **Native PHP Files:** Works with standard Laravel `lang/*.php` files.
- **No Database Required:** Lightweight and zero-setup.

🎥 Video Tutorial
----------------

[](#-video-tutorial)

You can see how LangGen works and how to use it in a real project in this YouTube video:

[![Laravel LangGen – Auto Generate Translations](https://camo.githubusercontent.com/52854d81656cba55412a7043b6ebcd28945e338aab6d65719b9cf5e59f1d6ce5/68747470733a2f2f696d672e796f75747562652e636f6d2f76692f554372316b5238724d79382f302e6a7067)](https://youtu.be/UCr1kR8rMy8)

👉 **Watch on YouTube:**

📦 Installation
--------------

[](#-installation)

You can install the package via composer:

```
composer require azizdevfull/lang-gen --dev
```

Optionally, you can publish the configuration file:

```
php artisan vendor:publish --tag="lang-gen-config"
```

🛠 Usage
-------

[](#-usage)

### Basic Usage

[](#basic-usage)

Run the command to scan your codebase and generate missing keys for the default language (default: `en`):

```
php artisan lang:gen
```

### Specify Language

[](#specify-language)

To generate translations for a specific language (e.g., Uzbek):

```
php artisan lang:gen uz
```

This will:

1. Scan your configured directories (default: `app`, `resources/views`, `routes`).
2. Find all translation keys (nested arrays and JSON strings).
3. Create or update `lang/uz/messages.php` and `lang/uz.json`.
4. Populate missing keys with a readable default value (e.g., "Messages Welcome").

⚙️ Configuration
----------------

[](#️-configuration)

The configuration file `config/lang-gen.php` allows you to customize the behavior:

```
