- Add LocaleSubscriber: detects browser language, honours session override (priority 20) - Add LocaleSwitchController: stores locale in session, linked from user menu - Add admin.en.yaml / admin.de.yaml translation files (95 keys each) - Wire translation fallback to EN in config/packages/translation.yaml - Replace all hard-coded strings in CRUD controllers with TranslatableMessage - Inject TranslatorInterface into DashboardController, ArticleCrudController, AIPipelineJobCrudController and PipelineStreamController; add locale switcher links (English / Deutsch) to the user menu - Add confirmation dialog to "Re-run AI" and "Retry" pipeline actions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
31 lines
968 B
PHP
31 lines
968 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Infrastructure\Http\Controller\Admin;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
use Symfony\Component\Security\Http\Attribute\IsGranted;
|
|
|
|
#[IsGranted('ROLE_USER')]
|
|
final class LocaleSwitchController extends AbstractController
|
|
{
|
|
private const array SUPPORTED = ['en', 'de'];
|
|
|
|
#[Route('/admin/locale/{locale}', name: 'admin_locale_switch', requirements: ['locale' => 'en|de'])]
|
|
public function switch(string $locale, Request $request): Response
|
|
{
|
|
if (!\in_array($locale, self::SUPPORTED, true)) {
|
|
$locale = 'en';
|
|
}
|
|
|
|
$request->getSession()->set('_locale', $locale);
|
|
|
|
$referer = $request->headers->get('referer');
|
|
|
|
return $this->redirect($referer ?: $this->generateUrl('easyadmin'));
|
|
}
|
|
}
|