Hi all. I added a route to my routes.php
to handle a translation button. Two buttons go to the route funcToggleLanguage
with the strLanguage
parameters. When clicked it will reload the same page but with a newly set language.
The thing is, if I am on the root url, then this doesn’t work. In stead it seems to loop
use Slim\App;
return function (App $app) {
$app->get('/', \App\Action\Home\HomeAction::class)->setName('root');
$app->get('/challenges', \App\Action\Challenge\ChallengeAction::class)->setName('challenges');
$app->get('/ventures', \App\Action\Venture\VentureAction::class)->setName('ventures');
$app->get('/{strLanguage}', function ($oRequest, $oResponse, $oArguments) {
if ($oArguments['strLanguage'] === 'nl') {
$_SESSION['strLocale'] = 'nl_NL';
}
if ($oArguments['strLanguage'] === 'en') {
$_SESSION['strLocale'] = 'en_US';
}
return $oResponse->withRedirect($_SESSION['strRouteFrom'], 302);
})->setName('funcToggleLanguage');
};