original_string: public function acceptLanguage($language = null)
      {
          $raw = $this->_parseAcceptWithQualifier($this->getHeaderLine('Accept-Language'));
          $accept = [];
          foreach ($raw as $languages) {
              foreach ($languages as &$lang) {
                  if (strpos($lang, '_')) {
                      $lang = str_replace('_', '-', $lang);
                  }
                  $lang = strtolower($lang);
              }
              $accept = array_merge($accept, $languages);
          }
          if ($language === null) {
              return $accept;
          }
  
          return in_array(strtolower($language), $accept);
      }
code: public function acceptLanguage($language = null)
      {
          $raw = $this->_parseAcceptWithQualifier($this->getHeaderLine('Accept-Language'));
          $accept = [];
          foreach ($raw as $languages) {
              foreach ($languages as &$lang) {
                  if (strpos($lang, '_')) {
                      $lang = str_replace('_', '-', $lang);
                  }
                  $lang = strtolower($lang);
              }
              $accept = array_merge($accept, $languages);
          }
          if ($language === null) {
              return $accept;
          }
  
          return in_array(strtolower($language), $accept);
      }
code_tokens: public function acceptLanguage ( $ language = null ) { $ raw = $ this -> _parseAcceptWithQualifier ( $ this -> getHeaderLine ( 'Accept-Language' ) ) ; $ accept = [ ] ; foreach ( $ raw as $ languages ) { foreach ( $ languages as & $ lang ) { if ( strpos ( $ lang , '_' ) ) { $ lang = str_replace ( '_' , '-' , $ lang ) ; } $ lang = strtolower ( $ lang ) ; } $ accept = array_merge ( $ accept , $ languages ) ; } if ( $ language === null ) { return $ accept ; } return in_array ( strtolower ( $ language ) , $ accept ) ; }
docstring: Get the languages accepted by the client, or check if a specific language is accepted.
  
  Get the list of accepted languages:
  
  ``` \Cake\Http\ServerRequest::acceptLanguage(); ```
  
  Check if a specific language is accepted:
  
  ``` \Cake\Http\ServerRequest::acceptLanguage('es-es'); ```
  
  @param string|null $language The language to test.
  @return array|bool If a $language is provided, a boolean. Otherwise the array of accepted languages.
docstring_tokens: Get the languages accepted by the client or check if a specific language is accepted .