PHPackages                             smmahfujurrahman/localization - 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. [Templating &amp; Views](/categories/templating)
4. /
5. smmahfujurrahman/localization

ActiveLibrary[Templating &amp; Views](/categories/templating)

smmahfujurrahman/localization
=============================

A Laravel package providing Artisan commands to extract, auto-translate, wrap, and sort Blade translation strings with Google Translate support.

v1.0.0(1mo ago)026MITPHPPHP ^8.1|^8.2|^8.3|^8.4

Since Apr 25Pushed 1mo agoCompare

[ Source](https://github.com/MahfujuRahman/localization)[ Packagist](https://packagist.org/packages/smmahfujurrahman/localization)[ Docs](https://github.com/MahfujuRahman/localization)[ RSS](/packages/smmahfujurrahman-localization/feed)WikiDiscussions main Synced 1w ago

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

Localization for Laravel
========================

[](#localization-for-laravel)

[![Latest Stable Version](https://camo.githubusercontent.com/d9350ae37f68c0b4c1ccc96dbed8be818b0b2e62a467d6b4885823f0a9c61304/68747470733a2f2f706f7365722e707567782e6f72672f736d6d616866756a75727261686d616e2f6c6f63616c697a6174696f6e2f76)](https://packagist.org/packages/smmahfujurrahman/localization)[![Total Downloads](https://camo.githubusercontent.com/9bce9297acd87e99fefbcfe0b999b077e312f8605d3db449ea34203d1fa928a6/68747470733a2f2f706f7365722e707567782e6f72672f736d6d616866756a75727261686d616e2f6c6f63616c697a6174696f6e2f646f776e6c6f616473)](https://packagist.org/packages/smmahfujurrahman/localization)[![License](https://camo.githubusercontent.com/a57fc2a798d5826796eb84d564c38649c1a5eb19228d078b6438a78ea74d8e8f/68747470733a2f2f706f7365722e707567782e6f72672f736d6d616866756a75727261686d616e2f6c6f63616c697a6174696f6e2f6c6963656e7365)](https://packagist.org/packages/smmahfujurrahman/localization)

A Laravel package that provides three Artisan commands to fully automate your translation workflow:

CommandWhat it does`localization:extract`Scans all Blade files for `__()` / `@lang()` calls and extracts keys to a JSON file. Optionally auto-translates via Google Translate.`localization:wrap`Scans all Blade files and wraps un-translated static text with `__()` automatically.`localization:sort`Sorts any translation JSON file alphabetically by key.---

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

[](#requirements)

- PHP **8.1+**
- Laravel **10, 11, or 12**
- Internet connection (for `localization:extract` with a target language)

---

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

[](#installation)

```
composer require smmahfujurrahman/localization
```

Laravel auto-discovers the service provider. No manual registration needed.

---

Publish Configuration (Recommended)
-----------------------------------

[](#publish-configuration-recommended)

```
php artisan vendor:publish --tag=localization-config
```

This creates `config/localization.php` where you can customise all paths and settings:

```
return [
    // Directory scanned by localization:wrap (default: resources/views)
    'views_path' => resource_path('views'),

    // Directory used by localization:extract and localization:sort
    // null = auto-detect (/lang on Laravel 9+, /resources/lang on older)
    'lang_path' => null,

    // Microsecond delay between Google Translate API calls (default: 100ms)
    'translate_delay' => 100000,

    // Backup directory prefix for localization:wrap (null = auto-generate)
    'backup_path' => null,

    // Filename for the empty key template (no language argument)
    'template_filename' => 'template_empty.json',

    // Source language for Google Translate (null = auto-detect)
    'source_language' => 'en',
];
```

---

Usage
-----

[](#usage)

### `localization:extract` — Extract &amp; Auto-Translate

[](#localizationextract--extract--auto-translate)

Scan all Blade views and extract every `__('...')` and `@lang('...')` key into a JSON file.

```
# Create an empty template (lang/template_empty.json)
php artisan localization:extract

# Auto-translate to French (creates lang/fr.json)
php artisan localization:extract fr

# Auto-translate to Arabic
php artisan localization:extract ar

# Auto-translate to Bengali
php artisan localization:extract bn

# Auto-translate to German
php artisan localization:extract de
```

**Smart re-run:** If a target language file already exists, keys that already have a translation are preserved — only new/missing keys are translated. You can re-run safely without overwriting manual edits.

---

### `localization:wrap` — Wrap Un-Translated Text

[](#localizationwrap--wrap-un-translated-text)

Automatically find static English text in your Blade files and wrap it with `__()`.

```
# Always preview first!
php artisan localization:wrap --dry-run

# Apply changes to all Blade files
php artisan localization:wrap
```

A timestamped backup of your views directory is created automatically before any files are modified.

**Handles 21 patterns including:**

- Simple tag text: `Dashboard` → `{{ __('Dashboard') }}`
- Dynamic variables: `{{ $type }} Management` → `{{ __(':type Management', ['type' => $type]) }}`
- HTML attributes: `placeholder`, `title`, `alt`, `label`
- Fallback values: `{{ $var ?? 'Default' }}` → `{{ $var ?? __('Default') }}`
- Button text, long paragraphs, emoji text, and more

---

### `localization:sort` — Sort a Translation File

[](#localizationsort--sort-a-translation-file)

Sort any JSON translation file alphabetically by key for easier management.

```
php artisan localization:sort ar.json
php artisan localization:sort fr.json
php artisan localization:sort en.json
```

---

Typical Workflow
----------------

[](#typical-workflow)

```
# Step 1: Wrap any un-translated text in your Blade files (dry run first)
php artisan localization:wrap --dry-run
php artisan localization:wrap

# Step 2: Extract all translation keys
php artisan localization:extract

# Step 3: Auto-translate to your target languages
php artisan localization:extract ar
php artisan localization:extract fr
php artisan localization:extract bn

# Step 4: Sort the files for easier management
php artisan localization:sort ar.json
php artisan localization:sort fr.json
```

---

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

Contributor
-----------

[](#contributor)

 [ ![](https://github.com/MahfujuRahman.png) ](https://github.com/MahfujuRahman)

 [ ![](https://camo.githubusercontent.com/85f1c52b4810c4ff5df1684b778c45ed7173af148a5ffb9ec4e78b50fea77bfd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f532e5f4d2e5f4d616866756a75725f5261686d616e2d536f6674776172655f456e67696e6565722d3066313732613f7374796c653d666f722d7468652d6261646765266c6f676f436f6c6f723d7768697465) ](https://github.com/MahfujuRahman)

 [ ![](https://camo.githubusercontent.com/154ae410ae98f6b13ff6c6de4e3d02852faa8ad35bc6ec1684e78eae4e99aa10/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f64796e616d69632f6a736f6e3f6c6162656c3d4f7267616e697a6174696f6e2671756572793d242e636f6d70616e792675726c3d68747470732533412532462532466170692e6769746875622e636f6d25324675736572732532464d616866756a755261686d616e26636f6c6f723d306439343838267374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465) ](https://github.com/MahfujuRahman) [ ![](https://camo.githubusercontent.com/cd9a561e98b220a73bea59f8b8f9d0f852ae14bc22a647ba20319fdb78005b56/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f50726f66696c652d566965775f436f6e7472696275746f722d3130623938313f7374796c653d666f722d7468652d6261646765266c6f676f3d676974687562266c6f676f436f6c6f723d7768697465) ](https://github.com/MahfujuRahman)

---

Support
-------

[](#support)

For support and questions:

- 📧 Email:

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance90

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

45d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/100138890?v=4)[S. M. Mahfujur Rahman](/maintainers/MahfujuRahman)[@MahfujuRahman](https://github.com/MahfujuRahman)

---

Top Contributors

[![MahfujuRahman](https://avatars.githubusercontent.com/u/100138890?v=4)](https://github.com/MahfujuRahman "MahfujuRahman (1 commits)")

---

Tags

laravellocalizationi18ntranslationbladeextractgoogle-translateauto-translate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/smmahfujurrahman-localization/health.svg)

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

###  Alternatives

[tightenco/jigsaw

Simple static sites with Laravel's Blade.

2.2k449.3k30](/packages/tightenco-jigsaw)[laravel/ai

The official AI SDK for Laravel.

9782.1M153](/packages/laravel-ai)[tallstackui/tallstackui

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

719160.4k12](/packages/tallstackui-tallstackui)[laravel-lang/publisher

Localization publisher for your Laravel application

2168.5M45](/packages/laravel-lang-publisher)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

4721.5k](/packages/erag-laravel-lang-sync-inertia)

PHPackages © 2026

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