code: protected function negotiateLanguage($request)
      {
          if (!empty($this->languageParam) && ($language = $request->get($this->languageParam)) !== null) {
              if (is_array($language)) {
                  // If an array received, then skip it and use the first of supported languages
                  return reset($this->languages);
              }
              if (isset($this->languages[$language])) {
                  return $this->languages[$language];
              }
              foreach ($this->languages as $key => $supported) {
                  if (is_int($key) && $this->isLanguageSupported($language, $supported)) {
                      return $supported;
                  }
              }
  
              return reset($this->languages);
          }
  
          foreach ($request->getAcceptableLanguages() as $language) {
              if (isset($this->languages[$language])) {
                  return $this->languages[$language];
              }
              foreach ($this->languages as $key => $supported) {
                  if (is_int($key) && $this->isLanguageSupported($language, $supported)) {
                      return $supported;
                  }
              }
          }
  
          return reset($this->languages);
      }
docs: Negotiates the application language.
  @param Request $request
  @return string the chosen language