original_string: 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();
      }
code: 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();
      }
code_tokens: 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 ( ) ; }
docstring: Check current locale, based on URI segments from the given URL
  
  @return mixed
docstring_tokens: Check current locale based on URI segments from the given URL