code: public function selectLocaleFromAcceptHeader(Accept $header)
      {
          // Collect a list of all supported locales
          $my_locales = [];
  
          foreach ($this->locales as $supported_locale)
          {
              $list = $supported_locale->getFallbackList();
              foreach ($list as $locale)
                  $my_locales[$locale->getLocale()] = $supported_locale->getLocale();
          }
  
          $best = $header->getBestResponseType(array_keys($my_locales));
          return empty($best) ? null : ($my_locales[$best] ?? null);
      }
docs: Find the best match between the locales this virtual host supports
  and the locales the client accepts.
  
  @param Accept $header The HTTP Accept header
  @return string The best matching locale