PHPackages                             yannxtrem/laralang - 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. yannxtrem/laralang

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

yannxtrem/laralang
==================

A Laravel package to extract translatable strings from views and Livewire components into a JSON file.

v1.0.0(5mo ago)140MITPHPPHP ^8.2

Since Jan 23Pushed 5mo agoCompare

[ Source](https://github.com/yannXtrem/laralang)[ Packagist](https://packagist.org/packages/yannxtrem/laralang)[ RSS](/packages/yannxtrem-laralang/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Laralang
========

[](#laralang)

[![Latest Stable Version](https://camo.githubusercontent.com/391ccfba674a23b04cb406df0f2288d05d2bb331681f9e36258dbbb9df01d4c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f79616e6e787472656d2f6c6172616c616e673f6c6162656c3d76657273696f6e)](https://camo.githubusercontent.com/391ccfba674a23b04cb406df0f2288d05d2bb331681f9e36258dbbb9df01d4c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f79616e6e787472656d2f6c6172616c616e673f6c6162656c3d76657273696f6e)[![License](https://camo.githubusercontent.com/2df69df4c09016d9c06e61bbdd28e06c28538498099b8e1ee62a61248e0e1fff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f79616e6e787472656d2f6c6172616c616e67)](https://camo.githubusercontent.com/2df69df4c09016d9c06e61bbdd28e06c28538498099b8e1ee62a61248e0e1fff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f79616e6e787472656d2f6c6172616c616e67)

**Laravel Lang Extractor** is a lightweight, zero-dependency development tool for Laravel 11 &amp; 12.

It automatically scans your application's Views and Livewire components to find translatable strings (using the `__('key')` helper), deduplicates them, and exports them into a clean JSON file ready for translation.

It replaces complex Bash scripts or heavy dependencies when you just need a simple JSON extraction.

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

[](#-features)

- **Recursive Scanning**: Scans `resources/views` (Blade files) and `app/Livewire` (Component classes).
- **Regex Extraction**: Detects `__('string')` and `__("string")`.
- **Smart Deduplication**: Automatically removes duplicate keys.
- **JSON Output**: Generates a valid JSON file compatible with Laravel's JSON translation support.
- **Unicode Support**: Preserves accents and special characters (no escaped Unicode sequences).
- **Laravel Native**: Fully integrated Artisan command.

📋 Requirements
--------------

[](#-requirements)

- PHP 8.2 or higher
- Laravel 11.0 or higher

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

[](#-installation)

Install the package via Composer as a development dependency:

```
composer require yannxtrem/laralang --dev
```

> **Note:** Since this tool is used during development to generate translation files, it is recommended to install it with the `--dev` flag.

🛠 Usage
-------

[](#-usage)

### Basic Extraction

[](#basic-extraction)

Run the artisan command to scan your project and generate the JSON file:

```
php artisan laralang:extract
```

By default, this will create a file named `a_trad.json` in your project root.

### Custom Output File

[](#custom-output-file)

You can specify the output filename and path using the `--output` option:

```
php artisan laralang:extract --output=lang/fr.json
```

Or for another language:

```
php artisan laralang:extract --output=lang/es.json
```

🔍 How it works
--------------

[](#-how-it-works)

1. **Scan**: The command looks for `*.php` and `*.blade.php` files in:
    - `resources/views/`
    - `app/Livewire/`
2. **Extract**: It applies a regex pattern to find usage of the Laravel translation helper:
    - Matches: `__('Hello World')`
    - Matches: `__("Hello World")`
3. **Process**:
    - Keys are sorted alphabetically.
    - Duplicates are removed.
4. **Save**: The result is saved as a JSON object where the key is the string found, and the value is an empty string (or the existing translation if you implement merging logic in the future).

### Example Output

[](#example-output)

```
{
    "Back to home": "",
    "Confirm password": "",
    "Login": "",
    "Welcome to our application": ""
}
```

⚡ Workflow Example
------------------

[](#-workflow-example)

1. Develop your features using `__('My text')` in Blade or PHP files.
2. Run `php artisan translation:extract --output=lang/fr.json`.
3. Open `lang/fr.json` and fill in the empty values with translations.
4. Laravel automatically uses these translations when the locale is set to `fr`.

🤝 Contribution
--------------

[](#-contribution)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the project
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

📄 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE.md).

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance72

Regular maintenance activity

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

Unknown

Total

1

Last Release

160d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/62825195?v=4)[yannXtrem](/maintainers/yannXtrem)[@yannXtrem](https://github.com/yannXtrem)

---

Top Contributors

[![yannXtrem](https://avatars.githubusercontent.com/u/62825195?v=4)](https://github.com/yannXtrem "yannXtrem (2 commits)")

### Embed Badge

![Health badge](/badges/yannxtrem-laralang/health.svg)

```
[![Health](https://phpackages.com/badges/yannxtrem-laralang/health.svg)](https://phpackages.com/packages/yannxtrem-laralang)
```

###  Alternatives

[laravel/sail

Docker files for running a basic Laravel application.

1.9k205.7M1.3k](/packages/laravel-sail)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M150](/packages/laravel-mcp)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

725172.4k14](/packages/tallstackui-tallstackui)[propaganistas/laravel-disposable-email

Disposable email validator

6023.0M7](/packages/propaganistas-laravel-disposable-email)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k90.5k1](/packages/mike-bronner-laravel-model-caching)

PHPackages © 2026

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