public function detectCurrentLanguage()
    {
        // parsing url to get only path & removing prefix if there is one
        $escapedPathPrefix = Text::escapeForRegex($this->config->getPathPrefix());
        $uriPath = parse_url($this->config->getRaw(), PHP_URL_PATH);
        $uriPath = preg_replace('/^' . $escapedPathPrefix . '/s', '', $uriPath);
        $uriSegments = explode('/', $uriPath);

        if (isset($uriSegments[1]) && in_array($uriSegments[1], $this->translate->getLanguages())) {
            return $uriSegments[1];
        }
        return $this->translate->getDefault();
    }
public function detectCurrentLanguage()
    {
        // parsing url to get only path & removing prefix if there is one
        $escapedPathPrefix = Text::escapeForRegex($this->config->getPathPrefix());
        $uriPath = parse_url($this->config->getRaw(), PHP_URL_PATH);
        $uriPath = preg_replace('/^' . $escapedPathPrefix . '/s', '', $uriPath);
        $uriSegments = explode('/', $uriPath);

        if (isset($uriSegments[1]) && in_array($uriSegments[1], $this->translate->getLanguages())) {
            return $uriSegments[1];
        }
        return $this->translate->getDefault();
    }
public function detectCurrentLanguage ( ) { // parsing url to get only path & removing prefix if there is one $ escapedPathPrefix = Text :: escapeForRegex ( $ this -> config -> getPathPrefix ( ) ) ; $ uriPath = parse_url ( $ this -> config -> getRaw ( ) , PHP_URL_PATH ) ; $ uriPath = preg_replace ( '/^' . $ escapedPathPrefix . '/s' , '' , $ uriPath ) ; $ uriSegments = explode ( '/' , $ uriPath ) ; if ( isset ( $ uriSegments [ 1 ] ) && in_array ( $ uriSegments [ 1 ] , $ this -> translate -> getLanguages ( ) ) ) { return $ uriSegments [ 1 ] ; } return $ this -> translate -> getDefault ( ) ; }
Check current locale, based on URI segments from the given URL

@return mixed
Check current locale based on URI segments from the given URL