LaravelPackages.net
Acme Inc.
Toggle sidebar
hendriarga/blade-localizer

Auto-scan and localize Laravel Blade UI text into language files

0
0
About hendriarga/blade-localizer

hendriarga/blade-localizer is a Laravel package for auto-scan and localize laravel blade ui text into language files. It currently has 0 GitHub stars and 0 downloads on Packagist. Install it with composer require hendriarga/blade-localizer. Discover more Laravel packages by hendriarga or browse all Laravel packages to compare alternatives.

Last updated

Blade Localizer

Blade Localizer is a Laravel package that scans your Blade .blade.php files, extracts UI strings, and adds them to your lang/{locale}/ui.php or ui.json translation files. It also supports auto-replacing static text with the __() helper and translating them using the Google Translate API.


✨ Features

  • πŸ” Scan HTML tags like div, span, label, a, button, p, and even custom components like <x-*>
  • πŸͺ„ Auto-replace static text with {{ __('...') }}
  • 🌐 Generate lang/{locale}/ui.php and ui.json files
  • 🌍 Automatic translation support via Google Translate API
  • 🧩 Detect translatable attributes like placeholder, title, aria-label, etc.
  • 🚫 Optionally skip already-translated strings using __('...')
  • ♻️ Avoids duplicate keys and appends new ones instead of overwriting
  • 🧠 Caches translation results for performance

πŸš€ Installation

composer require hendriarga/blade-localizer

πŸ“– Usage

1. Publish the config file

php artisan vendor:publish --tag=blade-localizer

4. Run the blade:localize Artisan command

php artisan localize:blade

This command will scan your Blade files, extract UI strings, and add them to your lang/{locale}/ui.php or ui.json files. It will also automatically replace static text with the __() helper and translate them using the Google Translate API.


πŸ“ Configuration

You can customize the behavior of the package by editing the config/blade-localizer.php file.

| Option | Description | Default | | --- | --- | --- | | locales | An array of locales to generate language files for. | ['en'] | | views | An array of folders to scan for Blade files. | ['resources/views'] | | filename | The name of the language file. | ui.php | | skip_keywords | An array of keywords to skip when extracting UI strings. | [] | | path | The path to the language file. Set to false to generate a new file. | false |


πŸ“ License

The package is open-sourced software licensed under the MIT license. Feel free to use, modify, and distribute this package as long as you follow the license terms.

Comments