src/Middleware/DetectLocaleMiddleware.php
public function process(HTTPRequest $request, callable $delegate)
    {
        $state = FluentState::singleton();
        $locale = $state->getLocale();

        if (!$locale) {
            $locale = $this->getLocale($request);
            $state->setLocale($locale);
        }

        if ($locale && $state->getIsFrontend()) {
            i18n::set_locale($state->getLocale());
        }

        // Persist the current locale if it has a value.
        // Distinguishes null from empty strings in order to unset locales.
        $newLocale = $state->getLocale();
        if (!is_null($newLocale)) {
            $this->setPersistLocale($request, $newLocale);
        }

        return $delegate($request);
    }
public function process(HTTPRequest $request, callable $delegate)
    {
        $state = FluentState::singleton();
        $locale = $state->getLocale();

        if (!$locale) {
            $locale = $this->getLocale($request);
            $state->setLocale($locale);
        }

        if ($locale && $state->getIsFrontend()) {
            i18n::set_locale($state->getLocale());
        }

        // Persist the current locale if it has a value.
        // Distinguishes null from empty strings in order to unset locales.
        $newLocale = $state->getLocale();
        if (!is_null($newLocale)) {
            $this->setPersistLocale($request, $newLocale);
        }

        return $delegate($request);
    }
public function process ( HTTPRequest $ request , callable $ delegate ) { $ state = FluentState :: singleton ( ) ; $ locale = $ state -> getLocale ( ) ; if ( ! $ locale ) { $ locale = $ this -> getLocale ( $ request ) ; $ state -> setLocale ( $ locale ) ; } if ( $ locale && $ state -> getIsFrontend ( ) ) { i18n :: set_locale ( $ state -> getLocale ( ) ) ; } // Persist the current locale if it has a value. // Distinguishes null from empty strings in order to unset locales. $ newLocale = $ state -> getLocale ( ) ; if ( ! is_null ( $ newLocale ) ) { $ this -> setPersistLocale ( $ request , $ newLocale ) ; } return $ delegate ( $ request ) ; }
Sets the current locale to the FluentState, provided no previous middleware has set it first

{@inheritDoc}
Sets the current locale to the FluentState provided no previous middleware has set it first