avris/localisator
Laravel package for localization: detect current locale, resolve language from request/user settings, and manage locale switching. Helps build multilingual apps with clean locale handling and integration points for routes, middleware, and views.
avris/localisator) aligns well with Laravel’s built-in localization system but offers a simpler, more declarative syntax for defining and managing translations. It could serve as a lightweight alternative to Laravel’s native trans() helper or packages like laravel-lang if the team prefers a YAML-based or attribute-driven approach.#[Localizable]) or YAML files, reducing clutter in Blade views and controllers. This fits well with modular architectures where localization is treated as a cross-cutting concern.trans() helper or other packages (e.g., spatie/laravel-translatable) if configured to use the same translation files.| Risk Area | Mitigation Strategy |
|---|---|
| Syntax Overhead | Evaluate whether #[Localizable] attributes add complexity vs. Blade {{ trans() }}. |
| YAML Parsing | Benchmark performance with large translation sets; consider caching. |
| Fallback Logic | Test edge cases (e.g., missing keys, nested fallbacks) to avoid runtime errors. |
| Migration Complexity | Plan for parallel testing if replacing Laravel’s native system. |
| Dependency Bloat | Assess if the package adds unnecessary abstractions (e.g., YAML parsing) for simple apps. |
trans()?app()->setLocale() for dynamic switching.@localize directives for views.| Phase | Action Items | Tools/Dependencies |
|---|---|---|
| Evaluation | - Compare Localisator vs. Laravel’s native system. | Benchmark scripts, translation samples. |
| - Test with a non-critical feature (e.g., admin panel). | Laravel + Localisator. | |
| Pilot | - Migrate one module (e.g., auth views) to Localisator. | YAML/JSON converters, CI checks. |
| Full Adoption | - Replace trans() with @localize in Blade. |
Blade find/replace, ESLint/PHPStan rules. |
| - Update fallback logic if using custom strategies. | Custom middleware. | |
| Optimization | - Cache translations aggressively. | Laravel Cache, Redis. |
| - Integrate with localization tools (e.g., Crowdin webhooks). | API clients, Git hooks. |
trans() helper. High if using competing packages (e.g., spatie/laravel-translatable).{user.name} placeholders).composer require avris/localisator.php artisan vendor:publish --provider="Avris\Localisator\LocalisatorServiceProvider".config/localisator.php.resources/lang/).@localize directives.Localizable attributes if applicable.trans() calls in templates and logic.trans('key') calls).#[Localizable]) adds PHP 8+ dependency.Localisator::missing()).boot() to avoid runtime parsing.| Scenario | Impact | Mitigation |
|---|---|---|
| Missing Translation Key | Broken UI or runtime errors. | Configure Localisator::missing() callback. |
| YAML Syntax Error | App crashes during parsing. | Validate files in CI (e.g., yamllint). |
| Cache Invalidation | Stale translations. | Use php artisan cache:clear or event listeners. |
| **Dynamic Locale |
How can I help you explore Laravel packages today?