artryazanov/artisan-translator
Artisan Translator streamlines Laravel localization: extracts raw text from Blade templates into translation keys, translates with Google Gemini in batches, preserves HTML/placeholders, and cleans unused language keys. Supports Laravel 11/12, PHP 8.2+.
lang/ directory, __() helper, Blade directives). It extends Laravel’s existing translation infrastructure rather than replacing it, reducing architectural disruption.config/, resources/lang/).@php) might not be fully supported without adjustments.artisan translate) could slow down workflows. Mitigation: Offer async/background processing.@php blocks or inline JavaScript handled?trans(), lang() files, Blade). No major framework changes required.fileinfo, curl for API calls)..env (e.g., GEMINI_API_KEY).google/cloud PHP SDK or HTTP client for API calls.resources/lang/).laravel-lang).lang/ directory.php artisan vendor:publish --provider="ArtisanTranslatorServiceProvider").config/artisan-translator.php (API key, default locale, ignored files/directories).php artisan translate:extract to generate missing keys.php artisan translate:gemini to auto-translate a subset of strings.php artisan translate:prune).translate:extract on template changes).@translate directive usage).@{{ }}, @php blocks with strings).spatie/laravel-translation-loader).artisan translate:extract.artisan translate:gemini for new strings.artisan-translator.php in version control with clear comments.composer why-not to track unused dependencies.@translate usage.monolog).translate:prune during low-traffic periods.Laravel Debugbar).translate:gemini).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Google Gemini API outage | Blocked translations | Fallback to cached translations or manual mode. |
| Rate limit exceeded | CI/CD pipeline failures | Implement retry logic with exponential backoff. |
| Blade parsing errors | Missing/incorrect extracted keys | Exclude problematic files/directives. |
| Unused-key pruning removes needed keys | Broken translations in production | Backup lang/ before pruning; test in staging. |
| API cost spikes | Unexpected charges | Set budget alerts; use manual mode for bulk ops. |
@translate directive and excluded patterns.How can I help you explore Laravel packages today?