@param string $language

@return StopWords

@throws InvalidArgumentException
550903
public static function factory($language = 'English'): StopWords
    {
        $className = __NAMESPACE__."\\StopWords\\$language";

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

        return new $className();
    }
817279
public function deleteStopWord($stopWord)
    {
        $this->initializeStopWordsUrl();
        if (empty($stopWord)) {
            throw new \InvalidArgumentException('Must provide stop word.');
        }

        return $this->_sendRawDelete($this->_stopWordsUrl . '/' . urlencode($stopWord));
    }
919751
public static function setLanguage($language)
    {
        if (! ($language instanceof Language)) {
            $language = Language::findByCode($language);
        }

        if (! $language) {
            return false;
        }

        App::setLocale($language->code);
        request()->setDefaultLocale($language->code);
        self::$language = $language;

        return $language;
    }
40783
public function setupLanguage($language = 'english')
    {
        $this
            ->addIndexAnalyzer($language)
            ->addSuggestionAnalyzer($language)
            ->addStripSpecialCharsFilter()
            ->addNGramTokenizer()
            ->addStopWordsFilter($language)
            ->addStemmerFilter($language);

        return $this;
    }
676597
public function setCurrentLocale($lang)
    {
        if ($lang === null) {
            $this->currentLanguage = null;
            return;
        }

        if (!$this->hasLocale($lang)) {
            if (!is_string($lang)) {
                $lang = is_object($lang) ? get_class($lang) : gettype($lang);
            }

            throw new InvalidArgumentException(sprintf(
                'Unsupported language; must be one of "%s", received "%s"',
                implode(', ', $this->availableLocales()),
                $lang
            ));
        }

        $this->currentLanguage = $lang;
    }
1130804
public static function setLanguage($language)
    {
        // regex source: http://www.w3.org/TR/xmlschema11-2/#language
        if (preg_match('/[a-z]{1,8}(-[a-z0-9]{1,8})*/i', $language) === 1) {
            self::$language = $language;
        } else {
            trigger_error('Invalid language tag: ' . $language, E_USER_WARNING);
        }
    }
275779
public function setLanguage($language)
    {
        $this->setLocale($language);

        $code = $this->getLanguageCode($language);

        putenv('LC_ALL=' . $code);
        setlocale(LC_ALL, $code);
        setlocale(LC_NUMERIC, 'en_US');

        return $this;
    }
783008
def custom_stopwords(stopwords)
      unless stopwords.is_a?(Enumerable)
        if stopwords.strip.empty?
          stopwords = []
        elsif File.exist?(stopwords)
          stopwords = File.read(stopwords).force_encoding('utf-8').split
        else
          return # Do not overwrite the default
        end
      end
      TokenFilter::Stopword::STOPWORDS[@language] = Set.new stopwords
    end
179676
public function getSlug($language = null)
    {
        $slugify = new Slugify();

        return $slugify->slugify($this->getTitle($language));
    }
318959
public function lang($language)
    {
        if (empty($language)) {
            $this->resetLang();
        } else {
            $this->lang = $language;
        }

        return $this;
    }
1162405
public function deleteSynonym($baseWord)
    {
        $this->initializeSynonymsUrl();
        if (empty($baseWord)) {
            throw new \InvalidArgumentException('Must provide base word.');
        }

        $response = $this->_sendRawDelete($this->_synonymsUrl . '/' . urlencode($baseWord));
        return $response;
    }
1156332
public function getKeyword($language = null)
    {
        if (empty($language)) {
            $language = $this->mainLanguageCode;
        }

        if (!is_array($this->keywords) || !array_key_exists($language, $this->keywords)) {
            return null;
        }

        return $this->keywords[$language];
    }
156331
private function getLanguage(string $language): string
    {
        $language = trim($language);

        if (strlen($language) === 2) {
            $language = "{$language}-{$language}";
        }

        if (!preg_match("/^[a-z]{2}-[a-z]{2}$/i", $language)) {
            throw new InvalidArgumentException("Unexpected language code ({$language}), codes should be 2 characters, a hyphen, and a further 2 characters");
        }

        list($main, $sub) = explode("-", $language);
        $language = strtolower($main) . "-" . strtoupper($sub);

        return $language;
    }
874858
private function assertLanguageIsValid(string $language): void
    {
        if (!$this->codeIsValid($language)) {
            throw new InvalidLanguageCodeException(
                sprintf("Language code \"%s\" is invalid", $language)
            );
        }
    }
845998
public function getSpecialTidsForLanguage($language = null)
    {
        $specialTids = [];

        foreach ($this->specialTids as $specialTid) {
            if ($specialTid['language'] === $language || $specialTid['language'] === null) {
                $specialTids[$specialTid['name']] = $specialTid['treeId'];
            }
        }

        return $specialTids;
    }
617394
public static function getLang($language)
    {
        $pos = strpos($language, '-');
        return $pos > 0 ? substr($language, 0, $pos) : $language;
    }
796643
static function setDefaultLanguage(string $language) {
        if(!\class_exists($language, true)) {
            throw new \InvalidArgumentException('Unknown language class');
        } elseif(!\in_array(\CharlotteDunois\Validation\LanguageInterface::class, \class_implements($language), true)) {
            throw new \InvalidArgumentException('Invalid language class (not implementing language interface)');
        }
        
        static::$defaultLanguage = $language;
    }