antfroger/dont-translate-bundle
symfony/framework-bundle:~2.3 and symfony/translation:~2.3), making it incompatible with modern Laravel (which uses a different architecture, e.g., service containers, routing, and translation systems).trans() helper, JSON translation files, and service provider). Laravel’s translation layer is fundamentally different from Symfony2’s Translator component.AppKernel. The bundle’s GET/cookie-based activation and role-based access would require a custom Laravel implementation (e.g., middleware, service provider, or translation filter).Translator with Loader interfaces (e.g., YamlFileLoader).Illuminate\Translation\Translator with array/JSON/XLF files and a service container.Translator wrapper would need a rewrite to integrate with Laravel’s trans() helper or Translator facade.APP_DEBUG=true already exposes translation keys in some contexts (e.g., php artisan translate:dump).trans() calls with keys).EventDispatcher with Laravel’s service container events.Translator decorator to Laravel’s Translator class.Gate or middleware).APP_DEBUG=true or php artisan translate:dump already achieve this?StripTranslationsMiddleware) a better fit?laravel-dont-translate) be more appropriate?roles config?trans() calls could degrade performance.ContainerInterface; Laravel uses Illuminate\Container.Request vs. Laravel’s Illuminate\Http\Request.Translator vs. Laravel’s Translator facade.EventListener with Laravel middleware.| Step | Action | Laravel Equivalent |
|---|---|---|
| 1 | Install via Composer | ❌ Not possible (Symfony2 dependency) |
| 2 | Register in AppKernel |
✅ Replace with Service Provider (register() method) |
| 3 | Configure af_dont_translate |
✅ Use Laravel’s config() or environment variables |
| 4 | Use GET/cookie toggling | ✅ Implement via middleware (check request()->query() or cookie()) |
| 5 | Role-based access | ✅ Use Laravel’s Gates, Policies, or middleware |
HttpFoundation, Translation)..yml; Laravel uses .json/.php. A custom loader would be needed to parse keys.APP_DEBUG, trans() key inspection).trans('key') with 'key').Translator with a debug mode.?show_keys=1) or cookie (show_keys=1).Gate for role-based access (e.g., ROLE_TRANSLATOR).trans('nested.key')).trans_choice()).trans(':count items', ['count' => 5])).Translator behavior differs from Laravel’s. Debugging would require deep knowledge of both stacks.trans() calls could slow down requests.| Scenario | Impact | Mitigation |
|---|---|---|
| Bundle Fails to Load | Broken translations site-wide | Fallback to default trans() behavior |
| GET/Cookie Toggle Leaks | Debug keys exposed in production | Environment-based disable (e.g., APP_ENV=production ignores toggle) |
| Role-Based Access Bypass | Unauthorized users see keys | Use Laravel’s Gates with strict role checks |
| Translation Key Parsing Error | App crashes on missing keys | Graceful fallback (e.g., return null or original key) |
| Symfony 2.3 Dependency Conflicts | Composer install fails | Isolate dependencies in a custom package |
Translator, service container, and Blade templating.How can I help you explore Laravel packages today?