PHPackages                             stevenbraham/laravel-blade-translations-extractor - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. stevenbraham/laravel-blade-translations-extractor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

stevenbraham/laravel-blade-translations-extractor
=================================================

Laravel package for auto extracting strings from \_\_ and @lang tags in Blade to JSON.

v1.0.0(5mo ago)021MITPHPPHP ^8.0

Since Nov 15Pushed 5mo agoCompare

[ Source](https://github.com/stevenbraham/laravel-blade-translations-extractor)[ Packagist](https://packagist.org/packages/stevenbraham/laravel-blade-translations-extractor)[ RSS](/packages/stevenbraham-laravel-blade-translations-extractor/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Laravel Blade Translations Extractor
====================================

[](#laravel-blade-translations-extractor)

A Laravel package that automatically scans Blade template files and PHP files for translatable strings and exports them to JSON translation files.

I could not find a suitable existing Laravel i18n package that could both scan Blade template files and export them to JSON with a `null` key. All existing solutions only supported `__`, did not capture all strings correctly, or could not add new strings as null to the JSON files etc. So I made this package with the help of Cursor and ChatGPT.

With a JSON file containing all strings as null values, you can easily translate them using a tool like [POEdit](https://poedit.net/).

Overview
--------

[](#overview)

This package helps you maintain your Laravel translation files by automatically extracting translatable strings from your Blade templates and PHP files. It scans for strings used with the `__()` helper function and `@lang()` Blade directive, then merges them into JSON translation files.

Features
--------

[](#features)

- 🔍 Automatically scans Blade templates (`.blade.php`) and PHP files (`.php`)
- 📝 Extracts translatable strings from `__()` and `@lang()` calls
- 🔄 Merges new strings into existing translation files without overwriting existing translations
- 🎯 Configurable regex pattern for custom translation function detection
- 📦 Zero configuration required - works out of the box

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

[](#installation)

Install the package via Composer:

```
composer require stevenbraham/laravel-blade-translations-extractor
```

The package will automatically register its service provider if you're using Laravel's package auto-discovery.

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Run the extraction command with your desired locale:

```
php artisan extract:translations en
```

This will:

1. Scan all `.blade.php` files in `resources/views/`
2. Scan all `.php` files in `app/`
3. Extract all translatable strings found in `__()` and `@lang()` calls
4. Merge new strings (with `null` values) into `lang/en.json`
5. Preserve existing translations in the JSON file

### Example

[](#example)

If you have a Blade template like this:

```
{{ __('Welcome to our website') }}
@lang('Please sign in to continue')
```

Running `php artisan extract:translations en` will create or update `lang/en.json`:

```
{
    "Please sign in to continue": null,
    "Welcome to our website": null
}
```

You can then fill in the translations manually or use a translation management tool.

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

[](#configuration)

### Publishing the Config File

[](#publishing-the-config-file)

To customize the extraction pattern, publish the configuration file:

```
php artisan vendor:publish --tag=extract-translations-config
```

This will create `config/laravel-blade-translations-extractor.php`.

### Customizing the Pattern

[](#customizing-the-pattern)

The default pattern matches `__()` and `@lang()` helper functions. You can customize it in the config file:

```
return [
    'pattern' => '/(?:__|@lang)\(\s*(["\'])(.*?)\1\s*[\),]/m',
];
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance69

Regular maintenance activity

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

178d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f9fb66dac9bcca01987e10f5675c2e97d79c9bf269b0cf64ca98ca544c779331?d=identicon)[stevenbraham](/maintainers/stevenbraham)

---

Top Contributors

[![stevenbraham](https://avatars.githubusercontent.com/u/1886415?v=4)](https://github.com/stevenbraham "stevenbraham (5 commits)")

### Embed Badge

![Health badge](/badges/stevenbraham-laravel-blade-translations-extractor/health.svg)

```
[![Health](https://phpackages.com/badges/stevenbraham-laravel-blade-translations-extractor/health.svg)](https://phpackages.com/packages/stevenbraham-laravel-blade-translations-extractor)
```

###  Alternatives

[wireui/wireui

TallStack components

1.8k1.3M16](/packages/wireui-wireui)[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[ramonrietdijk/livewire-tables

Dynamic tables for models with Laravel Livewire

21147.4k](/packages/ramonrietdijk-livewire-tables)

PHPackages © 2026

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