private function setLanguageFromBrowser(): void
    {
        $userLang = App::$Properties->get('singleLanguage');
        $browserAccept = $this->getLanguages();
        if (Any::isArray($browserAccept) && count($browserAccept) > 0) {
            foreach ($browserAccept as $bLang) {
                if (Arr::in($bLang, App::$Properties->get('languages'))) {
                    $userLang = $bLang;
                    break; // stop calculating, language is founded in priority
                }
            }
        }

        // parse query string
        $queryString = null;
        if (count($this->query->all()) > 0) {
            $queryString = '?' . http_build_query($this->query->all());
        }

        // build response with redirect to language-based path
        $redirectUrl = $this->getSchemeAndHttpHost() . $this->basePath . '/' . $userLang . $this->getPathInfo() . $queryString;
        $response = new RedirectResponse($redirectUrl);
        $response->send();
        exit();
    }
private function setLanguageFromBrowser(): void
    {
        $userLang = App::$Properties->get('singleLanguage');
        $browserAccept = $this->getLanguages();
        if (Any::isArray($browserAccept) && count($browserAccept) > 0) {
            foreach ($browserAccept as $bLang) {
                if (Arr::in($bLang, App::$Properties->get('languages'))) {
                    $userLang = $bLang;
                    break; // stop calculating, language is founded in priority
                }
            }
        }

        // parse query string
        $queryString = null;
        if (count($this->query->all()) > 0) {
            $queryString = '?' . http_build_query($this->query->all());
        }

        // build response with redirect to language-based path
        $redirectUrl = $this->getSchemeAndHttpHost() . $this->basePath . '/' . $userLang . $this->getPathInfo() . $queryString;
        $response = new RedirectResponse($redirectUrl);
        $response->send();
        exit();
    }
private function setLanguageFromBrowser ( ) : void { $ userLang = App :: $ Properties -> get ( 'singleLanguage' ) ; $ browserAccept = $ this -> getLanguages ( ) ; if ( Any :: isArray ( $ browserAccept ) && count ( $ browserAccept ) > 0 ) { foreach ( $ browserAccept as $ bLang ) { if ( Arr :: in ( $ bLang , App :: $ Properties -> get ( 'languages' ) ) ) { $ userLang = $ bLang ; break ; // stop calculating, language is founded in priority } } } // parse query string $ queryString = null ; if ( count ( $ this -> query -> all ( ) ) > 0 ) { $ queryString = '?' . http_build_query ( $ this -> query -> all ( ) ) ; } // build response with redirect to language-based path $ redirectUrl = $ this -> getSchemeAndHttpHost ( ) . $ this -> basePath . '/' . $ userLang . $ this -> getPathInfo ( ) . $ queryString ; $ response = new RedirectResponse ( $ redirectUrl ) ; $ response -> send ( ) ; exit ( ) ; }
Set language from browser headers
@return void
Set language from browser headers