public function detectLocale(): self
    {
        $locale = null;

        $detectors = [
            FallbackDetector::class,
            HiddenSegmentDetector::class,
            SegmentDetector::class,
            QueryDetector::class,
        ];

        foreach ($detectors as $detector) {
            $locale = app($detector)->get($this->getScope(), $this->config) ?? $locale;
        }

        $this->locale = $locale;

        Scope::setActiveLocale($locale);

        $this->setApplicationLocale();

        return $this;
    }
public function detectLocale(): self
    {
        $locale = null;

        $detectors = [
            FallbackDetector::class,
            HiddenSegmentDetector::class,
            SegmentDetector::class,
            QueryDetector::class,
        ];

        foreach ($detectors as $detector) {
            $locale = app($detector)->get($this->getScope(), $this->config) ?? $locale;
        }

        $this->locale = $locale;

        Scope::setActiveLocale($locale);

        $this->setApplicationLocale();

        return $this;
    }
public function detectLocale ( ) : self { $ locale = null ; $ detectors = [ FallbackDetector :: class , HiddenSegmentDetector :: class , SegmentDetector :: class , QueryDetector :: class , ] ; foreach ( $ detectors as $ detector ) { $ locale = app ( $ detector ) -> get ( $ this -> getScope ( ) , $ this -> config ) ?? $ locale ; } $ this -> locale = $ locale ; Scope :: setActiveLocale ( $ locale ) ; $ this -> setApplicationLocale ( ) ; return $ this ; }
Detect the locale from current request url.
Once the locale has been determined, it will be set as the application locale.
A locale is only validated if it is present within the current locale scope.

Detection honours following priority:
1) If locale is found in request as query parameter e.g. ?locale=fr,
2) If locale is found in request url, either from host or segment eg. nl.example.com, example.nl or example.com/nl
3) Otherwise set locale to our fallback language (app.locale)
Detect the locale from current request url . Once the locale has been determined it will be set as the application locale . A locale is only validated if it is present within the current locale scope .