tomatophp/filament-translations
Filament plugin to manage Laravel translations in the database with caching. Scan your code for trans()/__() keys, import strings, and edit translations via a UI. Built on spatie/laravel-translation-loader, with install command and panel plugin registration.
spatie/laravel-translation-loader (v1.6+) and Filament core. If the project already uses these, integration is seamless.AdminPanelProvider. No core Laravel modifications needed.| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Filament Version Lock | Hard dependency on Filament v4. Downgrading may break functionality. | Evaluate Filament upgrade path; test in staging before production rollout. |
| Scan Performance | CLI/queue-based scanning of PHP files for translation keys could be slow for large codebases. | Use use_queue_on_scan in config; test with a representative subset of files. |
| Customization Complexity | Hooks and resource overrides require PHP knowledge. | Document customization patterns; provide examples in the project’s README. |
| Translation Key Conflicts | Manual DB storage may lead to key collisions or orphaned entries. | Implement a pre-scan validation step or use Filament’s soft-deletes. |
| Third-Party Extensions | Auto-translation (e.g., ChatGPT/Google) adds external API dependencies. | Disable extensions if not needed; monitor API rate limits and costs. |
Localization Strategy:
.json/.php files)? If hybrid, how will conflicts be resolved?en as default) or strict locale isolation?Workflows:
Performance:
Extensibility:
Migration:
.json/.php translation files with a DB-backed system, ideal for:
| Step | Action | Tools/Commands |
|---|---|---|
| 1. Assessment | Audit existing translation files (.json, .php) and DB structure. |
php artisan filament-translations:scan --dry-run |
| 2. Setup | Install package and publish config/migrations. | composer require tomatophp/filament-translations php artisan vendor:publish --tag="filament-translations-migrations" |
| 3. Data Migration | Migrate existing translations to DB. | Custom script or filament-translations:import (if files are compatible). |
| 4. Configuration | Update config/filament-translations.php for: |
|
| - Locale settings. | ||
- Queue scanning (use_queue_on_scan). |
||
- UI button visibility (e.g., hide export if unused). |
||
| 5. Plugin Registration | Register the plugin in AdminPanelProvider. |
$panel->plugin(FilamentTranslationsPlugin::make()->allowCreate()->allowClearTranslations()) |
| 6. Testing | Validate scanning, UI CRUD, and fallback behavior. | PEST tests or manual testing with edge cases (e.g., missing translations). |
| 7. Rollout | Deploy to staging; monitor cache performance and scan times. | |
| 8. Optimization | Tune cache TTL, queue workers, or add indexes if DB queries are slow. | php artisan optimize:clear + Redis tuning. |
trans(), __(), and {{ __('key') }} syntax. Blade directives (e.g., @lang) may need manual extraction.Phase 1: Pilot
Phase 2: Full Migration
trans() calls with the new system (or use a facade for gradual adoption).config/app.php.Phase 3: Optimization
php artisan cache:clear or tag-based invalidation).translations table.filament-translations:scan --verbose.storage/logs/laravel.log for scan/import errors.debugbar to inspect translation keys during runtime.use_queue_on_scan) mitigates long CLI hangs.locale and key columns if >10K translations.How can I help you explore Laravel packages today?