original_string: public function beforeDispatch(Event $event)
      {
          /* @var \Cake\Http\ServerRequest $request */
          $request = $event->getData('request');
          $locale = Locale::acceptFromHttp($request->getHeaderLine('Accept-Language'));
  
          if (!$locale || (!empty($this->_locales) && !in_array($locale, $this->_locales))) {
              return;
          }
  
          I18n::setLocale($locale);
      }
code: public function beforeDispatch(Event $event)
      {
          /* @var \Cake\Http\ServerRequest $request */
          $request = $event->getData('request');
          $locale = Locale::acceptFromHttp($request->getHeaderLine('Accept-Language'));
  
          if (!$locale || (!empty($this->_locales) && !in_array($locale, $this->_locales))) {
              return;
          }
  
          I18n::setLocale($locale);
      }
code_tokens: public function beforeDispatch ( Event $ event ) { /* @var \Cake\Http\ServerRequest $request */ $ request = $ event -> getData ( 'request' ) ; $ locale = Locale :: acceptFromHttp ( $ request -> getHeaderLine ( 'Accept-Language' ) ) ; if ( ! $ locale || ( ! empty ( $ this -> _locales ) && ! in_array ( $ locale , $ this -> _locales ) ) ) { return ; } I18n :: setLocale ( $ locale ) ; }
docstring: Inspects the request for the Accept-Language header and sets the
  Locale for the current runtime if it matches the list of valid locales
  as passed in the configuration.
  
  @param \Cake\Event\Event $event The event instance.
  @return void
docstring_tokens: Inspects the request for the Accept - Language header and sets the Locale for the current runtime if it matches the list of valid locales as passed in the configuration .