Change app settings within Middleware

Hi everyone,

What would be the correct way to change the application settings within a Middleware?

I’m passing the container in the constructor like so:
$app->add(new \App\Middleware\Language($app->getContainer()));

Somewhere inside the middleware im doing:

$this->ci->get(‘settings’)[‘locale’] = $routeInfo[2][‘lang’];

return $next($request, $response);

Then, im trying to initialize the Symfony Translator dependency using the setting I’ve just set in the middleware, but ‘locale’ has not changed his value previously:

 $translator = new \Symfony\Component\Translation\Translator($c->get('settings')['locale'],
        new \Symfony\Component\Translation\MessageSelector());

Hi, where are you currently creating the instance of the Symfony Translator in your app? can you provide a bit more code so we can see the how the app is being bootstrapped please?