hendriarga/blade-localizer
Composer 安装命令:
composer require hendriarga/blade-localizer
包简介
Auto-scan and localize Laravel Blade UI text into language files
README 文档
README
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.phpandui.jsonfiles - 🌍 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.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-21