mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-01-19 08:42:48 +08:00
ac9a65945f
- Reduced app settings down to what's required. - Used new view-shared $locale object instead of using globals via config. - Aligned language used to default on "locale" instead of mixing locale/language. For #4501
35 lines
769 B
PHP
35 lines
769 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
|
|
$this->localeManager->setAppLocale($userLocale);
|
|
|
|
return $next($request);
|
|
}
|
|
}
|