Clears all inflection rules.

@param string|boolean $lang The language name to reset or `true` to reset all even defaults.
19786
public static function reset($lang = null)
    {
        if (is_string($lang)) {
            unset(static::$_singular[$lang]);
            unset(static::$_plural[$lang]);
            return;
        }
        static::$_singular = [];
        static::$_plural = [];

        if ($lang === true) {
            return;
        }

        /**
         * Initilalize the class with english inflector rules.
         */
        Inflector::singular('/([^s])s$/i', '\1', 'default');
        Inflector::plural('/([^s])$/i', '\1s', 'default');

        Inflector::singular('/(x|z|s|ss|ch|sh)es$/i', '\1', 'default');
        Inflector::plural('/(x|z|ss|ch|sh)$/i', '\1es', 'default');

        Inflector::singular('/ies$/i', 'y', 'default');
        Inflector::plural('/([^aeiouy]|qu)y$/i', '\1ies', 'default');

        Inflector::plural('/(meta|data)$/i', '\1', 'default');

        Inflector::irregular('child', 'children', 'default');
        Inflector::irregular('equipment', 'equipment', 'default');
        Inflector::irregular('information', 'information', 'default');
        Inflector::irregular('man', 'men', 'default');
        Inflector::irregular('news', 'news', 'default');
        Inflector::irregular('person', 'people', 'default');
        Inflector::irregular('woman', 'women', 'default');

        /**
         * Warning, using an "exhastive" list of rules will slow
         * down all singularizations/pluralizations generations.
         * So it may be preferable to only add the ones you are actually needed.
         *
         * Anyhow bellow a list english exceptions which are not covered by the above rules.
         */
        // Inflector::irregular('advice', 'advice', 'default');
        // Inflector::irregular('aircraft', 'aircraft', 'default');
        // Inflector::irregular('alias', 'aliases', 'default');
        // Inflector::irregular('alga', 'algae', 'default');
        // Inflector::irregular('alumna', 'alumnae', 'default');
        // Inflector::irregular('alumnus', 'alumni', 'default');
        // Inflector::irregular('analysis', 'analyses', 'default');
        // Inflector::irregular('antenna', 'antennae', 'default');
        // Inflector::irregular('automaton', 'automata', 'default');
        // Inflector::irregular('axis', 'axes', 'default');
        // Inflector::irregular('bacillus', 'bacilli', 'default');
        // Inflector::irregular('bacterium', 'bacteria', 'default');
        // Inflector::irregular('barracks', 'barracks', 'default');
        // Inflector::irregular('basis', 'bases', 'default');
        // Inflector::irregular('bellows', 'bellows', 'default');
        // Inflector::irregular('buffalo', 'buffaloes', 'default');
        // Inflector::irregular('bus', 'buses', 'default');
        // Inflector::irregular('bison', 'bison', 'default');
        // Inflector::irregular('cactus', 'cacti', 'default');
        // Inflector::irregular('cafe', 'cafes', 'default');
        // Inflector::irregular('calf', 'calves', 'default');
        // Inflector::irregular('cargo', 'cargoes', 'default');
        // Inflector::irregular('cattle', 'cattle', 'default');
        // Inflector::irregular('child', 'children', 'default');
        // Inflector::irregular('congratulations', 'congratulations', 'default');
        // Inflector::irregular('corn', 'corn', 'default');
        // Inflector::irregular('crisis', 'crises', 'default');
        // Inflector::irregular('criteria', 'criterion', 'default');
        // Inflector::irregular('curriculum', 'curricula', 'default');
        // Inflector::irregular('datum', 'data', 'default');
        // Inflector::irregular('deer', 'deer', 'default');
        // Inflector::irregular('die', 'dice', 'default');
        // Inflector::irregular('dregs', 'dregs', 'default');
        // Inflector::irregular('duck', 'duck', 'default');
        // Inflector::irregular('echo', 'echos', 'default');
        // Inflector::irregular('elf', 'elves', 'default');
        // Inflector::irregular('ellipsis', 'ellipses', 'default');
        // Inflector::irregular('embargo', 'embargoes', 'default');
        // Inflector::irregular('equipment', 'equipment', 'default');
        // Inflector::irregular('erratum', 'errata', 'default');
        // Inflector::irregular('evidence', 'evidence', 'default');
        // Inflector::irregular('eyeglasses', 'eyeglasses', 'default');
        // Inflector::irregular('fish', 'fish', 'default');
        // Inflector::irregular('focus', 'foci', 'default');
        // Inflector::irregular('foot', 'feet', 'default');
        // Inflector::irregular('fungus', 'fungi', 'default');
        // Inflector::irregular('gallows', 'gallows', 'default');
        // Inflector::irregular('genus', 'genera', 'default');
        // Inflector::irregular('goose', 'geese', 'default');
        // Inflector::irregular('gold', 'gold', 'default');
        // Inflector::irregular('grotto', 'grottoes', 'default');
        // Inflector::irregular('gymnasium', 'gymnasia', 'default');
        // Inflector::irregular('half', 'halves', 'default');
        // Inflector::irregular('headquarters', 'headquarters', 'default');
        // Inflector::irregular('hoof', 'hooves', 'default');
        // Inflector::irregular('hypothesis', 'hypotheses', 'default');
        // Inflector::irregular('information', 'information', 'default');
        // Inflector::irregular('graffito', 'graffiti', 'default');
        // Inflector::irregular('half', 'halves', 'default');
        // Inflector::irregular('hero', 'heroes', 'default');
        // Inflector::irregular('jewelry', 'jewelry', 'default');
        // Inflector::irregular('kin', 'kin', 'default');
        // Inflector::irregular('knife', 'knives', 'default');
        // Inflector::irregular('larva', 'larvae', 'default');
        // Inflector::irregular('leaf', 'leaves', 'default');
        // Inflector::irregular('legislation', 'legislation', 'default');
        // Inflector::irregular('life', 'lives', 'default');
        // Inflector::irregular('loaf', 'loaves', 'default');
        // Inflector::irregular('locus', 'loci', 'default');
        // Inflector::irregular('louse', 'lice', 'default');
        // Inflector::irregular('luck', 'luck', 'default');
        // Inflector::irregular('luggage', 'luggage', 'default');
        // Inflector::irregular('man', 'men', 'default');
        // Inflector::irregular('mathematics', 'mathematics', 'default');
        // Inflector::irregular('matrix', 'matrices', 'default');
        // Inflector::irregular('means', 'means', 'default');
        // Inflector::irregular('measles', 'measles', 'default');
        // Inflector::irregular('medium', 'media', 'default');
        // Inflector::irregular('memorandum', 'memoranda', 'default');
        // Inflector::irregular('money', 'monies', 'default');
        // Inflector::irregular('moose', 'moose', 'default');
        // Inflector::irregular('mosquito', 'mosquitoes', 'default');
        // Inflector::irregular('motto', 'mottoes', 'default');
        // Inflector::irregular('mouse', 'mice', 'default');
        // Inflector::irregular('mumps', 'mumps', 'default');
        // Inflector::irregular('music', 'music', 'default');
        // Inflector::irregular('mythos', 'mythoi', 'default');
        // Inflector::irregular('nebula', 'nebulae', 'default');
        // Inflector::irregular('neurosis', 'neuroses', 'default');
        // Inflector::irregular('news', 'news', 'default');
        // Inflector::irregular('nucleus', 'nuclei', 'default');
        // Inflector::irregular('numen', 'numina', 'default');
        // Inflector::irregular('oasis', 'oases', 'default');
        // Inflector::irregular('oats', 'oats', 'default');
        // Inflector::irregular('octopus', 'octopuses', 'default');
        // Inflector::irregular('offspring', 'offspring', 'default');
        // Inflector::irregular('ovum', 'ova', 'default');
        // Inflector::irregular('ox', 'oxen', 'default');
        // Inflector::irregular('pajamas', 'pajamas', 'default');
        // Inflector::irregular('pants', 'pants', 'default');
        // Inflector::irregular('paralysis', 'paralyses', 'default');
        // Inflector::irregular('parenthesis', 'parentheses', 'default');
        // Inflector::irregular('person', 'people', 'default');
        // Inflector::irregular('phenomenon', 'phenomena', 'default');
        // Inflector::irregular('pike', 'pike', 'default');
        // Inflector::irregular('plankton', 'plankton', 'default');
        // Inflector::irregular('pliers', 'pliers', 'default');
        // Inflector::irregular('polyhedron', 'polyhedra', 'default');
        // Inflector::irregular('potato', 'potatoes', 'default');
        // Inflector::irregular('quiz', 'quizzes', 'default');
        // Inflector::irregular('radius', 'radii', 'default');
        // Inflector::irregular('roof', 'roofs', 'default');
        // Inflector::irregular('salmon', 'salmon', 'default');
        // Inflector::irregular('scarf', 'scarves', 'default');
        // Inflector::irregular('scissors', 'scissors', 'default');
        // Inflector::irregular('self', 'selves', 'default');
        // Inflector::irregular('series', 'series', 'default');
        // Inflector::irregular('shears', 'shears', 'default');
        // Inflector::irregular('sheep', 'sheep', 'default');
        // Inflector::irregular('shelf', 'shelves', 'default');
        // Inflector::irregular('shorts', 'shorts', 'default');
        // Inflector::irregular('silver', 'silver', 'default');
        // Inflector::irregular('species', 'species', 'default');
        // Inflector::irregular('squid', 'squid', 'default');
        // Inflector::irregular('stimulus', 'stimuli', 'default');
        // Inflector::irregular('stratum', 'strata', 'default');
        // Inflector::irregular('swine', 'swine', 'default');
        // Inflector::irregular('syllabus', 'syllabi', 'default');
        // Inflector::irregular('synopsis', 'synopses', 'default');
        // Inflector::irregular('synthesis', 'syntheses', 'default');
        // Inflector::irregular('tax', 'taxes', 'default');
        // Inflector::irregular('terminus', 'termini', 'default');
        // Inflector::irregular('thesis', 'theses', 'default');
        // Inflector::irregular('thief', 'thieves', 'default');
        // Inflector::irregular('tomato', 'tomatoes', 'default');
        // Inflector::irregular('tongs', 'tongs', 'default');
        // Inflector::irregular('tooth', 'teeth', 'default');
        // Inflector::irregular('torpedo', 'torpedoes', 'default');
        // Inflector::irregular('torus', 'tori', 'default');
        // Inflector::irregular('trousers', 'trousers', 'default');
        // Inflector::irregular('trout', 'trout', 'default');
        // Inflector::irregular('tweezers', 'tweezers', 'default');
        // Inflector::irregular('vertebra', 'vertebrae', 'default');
        // Inflector::irregular('vertex', 'vertices', 'default');
        // Inflector::irregular('vespers', 'vespers', 'default');
        // Inflector::irregular('veto', 'vetoes', 'default');
        // Inflector::irregular('volcano', 'volcanoes', 'default');
        // Inflector::irregular('vortex', 'vortices', 'default');
        // Inflector::irregular('vita', 'vitae', 'default');
        // Inflector::irregular('virus', 'viri', 'default');
        // Inflector::irregular('wheat', 'wheat', 'default');
        // Inflector::irregular('wife', 'wives', 'default');
        // Inflector::irregular('wolf', 'wolves', 'default');
        // Inflector::irregular('woman', 'women', 'default');
        // Inflector::irregular('zero', 'zeros', 'default');
    }
198268
public function setLanguageId( $langid )
	{
		if ( $langid == $this->getLanguageId() ) { return; }

		$this->_checkLanguageId( $langid );
		$this->_values['langid'] = $langid;
		$this->setModified();
	}
659931
public function validLang($lang)
    {
        if (in_array($lang, $this->validLanguages)) {
            return $lang;
        }
        if ($this->defaultLanguage) {
            return $this->defaultLanguage;
        }
        return false;
    }
318959
public function lang($language)
    {
        if (empty($language)) {
            $this->resetLang();
        } else {
            $this->lang = $language;
        }

        return $this;
    }
1015339
public function removeLanguageValues($values)
    {
        $this->_languageValues = array_diff($this->getLanguageValues(true), $this->filterLanguageValues($values));
    }
55488
public function setLang($lang)
    {
    	// Argument Validation
    	if (gettype($lang) != 'string')
        	throw new CAS_TypeMismatchException($lang, '$lang', 'string');

        phpCAS::traceBegin();
        $obj = new $lang();
        if (!($obj instanceof CAS_Languages_LanguageInterface)) {
            throw new CAS_InvalidArgumentException(
                '$className must implement the CAS_Languages_LanguageInterface'
            );
        }
        $this->_lang = $lang;
        phpCAS::traceEnd();
    }
502264
public function cleanLanguages()
    {
        // Delete any languages that were created.
        foreach ($this->languages as $language) {
            $this->getDriver()->languageDelete($language);
            unset($this->languages[$language->langcode]);
        }
    }
1202064
public function removeLanguage($language)
    {
        $language = (string)$language;
        if (isset($this->entries[$language])) {
            unset($this->entries[$language]);
        }
        return $this;
    }
285930
public function setLang(Lang $language = null)
    {
        $this->language = $language;

        if ($this->originalOrderAndAliases === null) {
            $this->originalOrderAndAliases = $this->orderAndAliases;
        }

        if ($this->language !== null && $this->orderAndAliases !== null) {
            $previousLocale = Translator::getInstance()->getLocale();

            Translator::getInstance()->setLocale($this->language->getLocale());
            foreach ($this->orderAndAliases as &$alias) {
                $alias = Translator::getInstance()->trans($alias);
            }

            Translator::getInstance()->setLocale($previousLocale);
        }

        return $this;
    }
926563
protected function loadInflection(string $language): void
	{
		$this->inflections[$language] = $this->loader->loadInflection($language);
	}
1296010
public function setLanguage($language, $force_reset = false)
    {
        if ($force_reset) {
            $this->loaded_language = false;
        }

        // Clean up the language name to prevent malicious code injection
        $language = preg_replace('#[^a-zA-Z0-9\-_]#', '', $language);

        $language = strtolower($language);

        // Retrieve the full filename
        $file_name = self::LANG_ROOT . $language . '.php';
        if ($file_name == $this->loaded_language) {
            // this language is already loaded!
            return;
        }

        $this->language = $language;

        $this->error = false;
        $this->strict_mode = self::NEVER;

        //Check if we can read the desired file
        if (!is_readable($file_name)) {
            $this->error = self::ERROR_NO_SUCH_LANG;

            return;
        }

        // Load the language for parsing
        $this->load_language($file_name);
    }
150391
public function setTranslatableLang($lang)
    {
        if (is_string($lang)) {
            $lang = new Lang($lang);
        }

        $this->translatableLang = $lang;

        return $this;
    }
10141
public function setLang(\Core\Entity\Language $lang = null)
    {
        $this->lang = $lang;

        return $this;
    }
113679
private function setIfAllowed($lang)
    {
        $allowedLangs = array_keys(Localizer::allowedLanguages());
        if (config('localizer.block_unallowed_langs') && !in_array($lang, $allowedLangs)) {
            $lang = $allowedLangs[0];
        }

        App::setLocale($lang);
        if (config('localizer.carbon')) {
            Carbon::setLocale($lang);
        }
    }
874858
private function assertLanguageIsValid(string $language): void
    {
        if (!$this->codeIsValid($language)) {
            throw new InvalidLanguageCodeException(
                sprintf("Language code \"%s\" is invalid", $language)
            );
        }
    }
702414
protected function plural_rules($lang)
	{
		if ( ! isset($this->_rules[$lang]))
		{
			// Get language code prefix
			$parts = explode('-', $lang, 2);
			$this->_rules[$lang] = $this->plural_rules_factory()
				->create_rules($parts[0]);
		}
		return $this->_rules[$lang];
	}
702209
public function reset()
    {
        // Remove all rules and messages
        $this->rules = [];
        $this->messages = ['rules' => [], 'custom' => []];
        $this->clear();

        // Add the initial rules and messages
        Validate::addRuleSet($this);
        $this->setLanguage($this->lang, $this->langDir);

        return $this;
    }