BookStackApp_BookStack/app/Http/Middleware/Localization.php
Dan Brown 78bf11cf65
Locales: Removed a lot of existing locale handling
There was a lot of locale handling to get correct/expected date
formatting within the app.
Carbon now has built-in locale content rather than us needing to target
specific system locales.

This also removes setting locale via Carbon directly.
Carbon registers its own Laravel service provider which seems to
accurately pull the correct locale from the app.

For #4555
2023-09-17 22:02:12 +01:00

35 lines
764 B
PHP

<?php
namespace BookStack\Http\Middleware;
use BookStack\Translation\LocaleManager;
use Closure;
class Localization
{
public function __construct(
protected LocaleManager $localeManager
) {
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
*
* @return mixed
*/
public function handle($request, Closure $next)
{
// Share details of the user's locale for use in views
$userLocale = $this->localeManager->getForUser(user());
view()->share('locale', $userLocale);
// Set locale for system components
app()->setLocale($userLocale->appLocale());
return $next($request);
}
}