Define the language of the error and other api messages

@param string $accept_language

@throws \InvalidArgumentException If the given param is invalid

@return self
765395
public function setAcceptLanguage($accept_language)
    {
        $accept_language = strtolower($accept_language);

        if (!in_array($accept_language, [self::ACCEPT_LANGUAGE_EN, self::ACCEPT_LANGUAGE_DE])) {
            throw new \InvalidArgumentException('Parameter "accept_language" must be valid');
        }

        $this->accept_language = $accept_language;
        return $this;
    }
914705
public function setLang($lang)
    {
        if (2 !== strlen($lang)) {
            throw new \InvalidArgumentException('Language identifier should be 2 characters long.');
        }

        if (!in_array($lang, $this->getSupportedLanguages())) {
            throw new \InvalidArgumentException(sprintf('Language "%s" is not supported.', $lang));
        }

        $this->lang = $lang;

        return $this;
    }
1051967
private function resolveToLanguage(array $parameters): Language
    {
        if (isset($parameters['toLanguage'])) {
            return $parameters['toLanguage'];
        }

        if (isset($parameters['toLanguageCode'])) {
            return $this->loadLanguage($parameters['toLanguageCode']);
        }

        throw new InvalidArgumentException(
            'Language',
            'No language information provided. Are you missing \'toLanguage\' or \'toLanguageCode\' parameters'
        );
    }
550903
public static function factory($language = 'English'): StopWords
    {
        $className = __NAMESPACE__."\\StopWords\\$language";

        if (!class_exists($className)) {
            throw InvalidArgumentException::invalidStopWordsLanguage($language);
        }

        return new $className();
    }
8386
public function language(array &$submitted, array $options = array())
    {
        $this->options = $options;
        $this->submitted = &$submitted;

        $this->validateLanguage();
        $this->validateWeight();
        $this->validateBool('status');
        $this->validateBool('default');
        $this->validateNameLanguage();
        $this->validateNativeNameLanguage();
        $this->validateCodeLanguage();

        $this->unsetSubmitted('update');

        return $this->getResult();
    }
173343
def home_language=(home_language)
      validator = EnumAttributeValidator.new('String', ["English", "Albanian", "Amharic", "Arabic", "Bengali", "Bosnian", "Burmese", "Cantonese", "Chinese", "Dutch", "Farsi", "French", "German", "Hebrew", "Hindi", "Hmong", "Ilocano", "Japanese", "Javanese", "Karen", "Khmer", "Korean", "Laotian", "Latvian", "Malay", "Mandarin", "Nepali", "Oromo", "Polish", "Portuguese", "Punjabi", "Romanian", "Russian", "Samoan", "Serbian", "Somali", "Spanish", "Swahili", "Tagalog", "Tamil", "Telugu", "Thai", "Tigrinya", "Turkish", "Ukrainian", "Urdu", "Vietnamese"])
      unless validator.valid?(home_language)
        fail ArgumentError, "invalid value for 'home_language', must be one of #{validator.allowable_values}."
      end
      @home_language = home_language
    end
199540
protected function checkLanguageParameter() {
    if ($this->request->hasValue('language')) {
      $language = $this->request->getValue('language');
      if (!in_array($language, array_keys($this->localization->getSupportedLanguages()))) {
        $this->response->addError(ApplicationError::get('PARAMETER_INVALID',
                ['invalidParameters' => ['language']]));
        return false;
      }
    }
    return true;
  }
874858
private function assertLanguageIsValid(string $language): void
    {
        if (!$this->codeIsValid($language)) {
            throw new InvalidLanguageCodeException(
                sprintf("Language code \"%s\" is invalid", $language)
            );
        }
    }
257696
private function sort(array $acceptLanguages)
    {
        $topAcceptLanguages = [];
        $sortedAcceptLanguages = [];

        foreach ($acceptLanguages as $acceptLanguage) {
            if ($acceptLanguage->getQuality() === 1.0) {
                $topAcceptLanguages[] = $acceptLanguage;
            } else {
                $sortedAcceptLanguages[] = $acceptLanguage;
            }
        }

        usort($sortedAcceptLanguages, function (AcceptLanguage $a, AcceptLanguage $b) {
            return $a->getQuality() > $b->getQuality() ? -1 : 1;
        });

        return array_merge($topAcceptLanguages, $sortedAcceptLanguages);
    }
950037
protected function setPublicationLanguage($language)
    {
        self::writeFullTag(
            $language,
            'name',
            false,
            'news:language',
            $this->validator,
            'validateLanguage',
            $this->exception,
            'Provided publication language is not a valid value.'
        );

        return $this;
    }
67676
public function addTranslationArray(array $translations, $language)
    {
        $language = (string) $language;
        if ($language === '') {
            throw new \InvalidArgumentException('$language cannot be empty');
        }

        if (!isset($this->translations[$language])) {
            $this->translations[$language] = [];
        }

        $this->translations[$language] = array_merge(
            $this->translations[$language],
            $translations
        );
    }
6482
public function addSupportedLanguage($language, $name = "defaultTranslationService", $selfedit="false") {
		$this->addTranslationLanguageFromService(($selfedit == "true"), $name, $language);
		
		// Once more to reaload languages list
		$this->supportedLanguages($name, $selfedit);
	}
990911
protected function detectLang()
    {
        /*
         * HTTP_ACCEPT_LANGUAGE -> fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
         * First "fr-FR" (preference 1/1)
         * After in the order, "fr" (preference 0.8 / 1)
         * Next "en-US" (preference 0.6/1)
         * End "en" (preference 0.4/1)
         **/
        
        $acceptLanguage = $this->serverValue('HTTP_ACCEPT_LANGUAGE');
        if (empty($acceptLanguage)) {
            $this->lang = '';
            return;
        }
        
        $acceptedLangs = explode(',', $acceptLanguage);
        $firstLang     = explode(';', $acceptedLangs[0]);
        $lang          = strtolower($firstLang[0]);

        if (strpos($lang, '-') !== false) {
            $minLang = explode('-', $lang);
            $lang    = $minLang[0];
        }

        $this->lang = $lang;
    }
1030596
public Request acceptLanguage(String language){
        final String acceptLanguage = RequestHeaderFields.ACCEPT_LANGUAGE.getName();
        String languageValue = headers.get(acceptLanguage);
        if (languageValue == null){
            languageValue = language;
        } else {
            languageValue = languageValue + ", " + language;
        }
        return this.setHeader(acceptLanguage, languageValue);
    }
1264190
public function setEthnicOrigin($ethnicOrigin)
    {
        if (!is_string($ethnicOrigin) && !is_null($ethnicOrigin)) {
            throw new \InvalidArgumentException(__CLASS__ . ' ' . __METHOD__ . ': Not a string');
        }

        $this->ethnicOrigin = $ethnicOrigin;

        return $this;
    }
507488
public function setLanguage($language)
    {
        if (!array_key_exists($language, $this->allowedlanguages)) {
            throw new InvalidArgumentException("Invalid language ISO code");
        }
        $this->parameters['language'] = $language;
    }
271372
public function setLanguage($language)
	{
        if (! $this->exists($language)) {
            $language = $this->_default;
        }

        $this->_language = $language;
        $this->_meta = $this->getMetadata($this->_language);
        $local = $this->getLocale();
        setlocale(LC_TIME, $local);

		return $this;
	}