Ajout de la traduction (#15)
Co-authored-by: hugo.pradier2 <hugo.pradier2@etu.uca.fr> Co-authored-by: clfreville2 <clement.freville2@etu.uca.fr> Reviewed-on: https://codefirst.iut.uca.fr/git/clement.freville2/herbarium/pulls/15 Reviewed-by: Clément FRÉVILLE <clement.freville2@etu.uca.fr> Co-authored-by: Hugo PRADIER <hugo.pradier2@etu.uca.fr> Co-committed-by: Hugo PRADIER <hugo.pradier2@etu.uca.fr>
This commit is contained in:
20
src/Controller/SettingController.php
Normal file
20
src/Controller/SettingController.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
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\Translation\LocaleSwitcher;
|
||||
|
||||
class SettingController extends AbstractController
|
||||
{
|
||||
#[Route('/setting/{locale}', name: 'app_setting_locale')]
|
||||
public function index(LocaleSwitcher $localeSwitcher, string $locale, Request $request): Response
|
||||
{
|
||||
$localeSwitcher->setLocale($locale);
|
||||
$request->getSession()->set('_locale', $locale);
|
||||
return $this->redirectToRoute('app_posts');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user