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(3mo ago)12MITPHPPHP ^8.2

Since Jan 23Pushed 3mo agoCompare

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

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

37

—

LowBetter than 82% of packages

Maintenance85

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

105d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79eb01e9a298505a276eab8644700fe92c5e6e02a626ded3bdb0c281c10aaed7?d=identicon)[yannXtrem](/maintainers/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

[fumeapp/modeltyper

Generate TypeScript interfaces from Laravel Models

196277.9k](/packages/fumeapp-modeltyper)[nikaia/translation-sheet

Laravel Translation via Google Spreadsheet

294606.4k1](/packages/nikaia-translation-sheet)[kerigard/laravel-lang-ru

Ru lang for Laravel

2116.8k](/packages/kerigard-laravel-lang-ru)[highsolutions/laravel-translation-manager

Manage Laravel Translations

1518.8k](/packages/highsolutions-laravel-translation-manager)[amendozaaguiar/laravel-lat-es

Archivos de traducción al español latinoamericano para Laravel (auth, pagination, passwords, validation).

198.5k](/packages/amendozaaguiar-laravel-lat-es)[amendozaaguiar/laraveles-spanish-for-jetstream

Archivos de traducción al español latinoamericano para Laravel con Jetstream (auth, pagination, passwords, validation + todas las cadenas de Jetstream).

1412.1k](/packages/amendozaaguiar-laraveles-spanish-for-jetstream)

PHPackages © 2026

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