mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-12-22 11:48:28 +00:00
78bf11cf65
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
35 lines
764 B
PHP
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);
|
|
}
|
|
}
|