Takes into account special rules due to multiple languages per extension.
329666
public static String getFormat(String fileName) {
        int lastDot = fileName.lastIndexOf('.');
        if (lastDot == -1)
            return null;
        return getLanguage(fileName.substring(lastDot));
    }
496371
function modifyOutRule(rule, type) {
	rule.test = new RegExp(
		'\\.(' + Config.out[type].extensions.join('|') + ')$'
	);
}
177879
public function addDependentExtension($rule, $extension)
    {
        $this->addExtension($rule, $extension);

        $this->dependentRules[] = Str::studly($rule);
    }
54356
public PluralRules forLocale(ULocale locale, PluralRules.PluralType type) {
        String rulesId = getRulesIdForLocale(locale, type);
        if (rulesId == null || rulesId.trim().length() == 0) {
            return PluralRules.DEFAULT;
        }
        PluralRules rules = getRulesForRulesId(rulesId);
        if (rules == null) {
            rules = PluralRules.DEFAULT;
        }
        return rules;
    }
752137
function (lang) {
		if (lang_data[lang] && lang_data[lang].error_callbacks && lang_data[lang].error_callbacks.length) {
			lang_data[lang].error_callbacks.forEach(function (f) {
				f(lang);
			});
		}
	}
1051524
private InternalLocaleBuilder setExtensions(List<String> bcpExtensions, String privateuse) {
        clearExtensions();

        if (!LocaleUtils.isEmpty(bcpExtensions)) {
            Set<CaseInsensitiveChar> done = new HashSet<>(bcpExtensions.size());
            for (String bcpExt : bcpExtensions) {
                CaseInsensitiveChar key = new CaseInsensitiveChar(bcpExt);
                // ignore duplicates
                if (!done.contains(key)) {
                    // each extension string contains singleton, e.g. "a-abc-def"
                    if (UnicodeLocaleExtension.isSingletonChar(key.value())) {
                        setUnicodeLocaleExtension(bcpExt.substring(2));
                    } else {
                        if (extensions == null) {
                            extensions = new HashMap<>(4);
                        }
                        extensions.put(key, bcpExt.substring(2));
                    }
                }
                done.add(key);
            }
        }
        if (privateuse != null && privateuse.length() > 0) {
            // privateuse string contains prefix, e.g. "x-abc-def"
            if (extensions == null) {
                extensions = new HashMap<>(1);
            }
            extensions.put(new CaseInsensitiveChar(privateuse), privateuse.substring(2));
        }

        return this;
    }
766577
public function actionDeleteAll()
    {
        
    	// Get the list of languages that will be deleted.
    	$this->outVerbose("Deleting all languages for extension '" . $this->options['extension'] . "'...");

		$locales = $this->getLanguageList();
    	
    	foreach ($locales as $l) {
    		$this->options['language'] = $l;
    		$this->checkDeleteInput();
    		$this->actionDelete();
    		
    		$this->outVerbose("");
    	}
        
    }
329880
function(_string, _locale) {
            var rules = loadRulesFor(_locale);
            return rules ? applyRules(_string, rules.singular, rules.uncountable) : _string;
          }
648894
public function actionCompileAll()
    {
        
        // Get the list of languages that will be compiled.
        $this->outVerbose("Compiling all languages for extension '" . $this->options['extension'] . "'...");
        
        $rootDir = ROOT_PATH;
        $extensionDir = $rootDir . '/' . $this->options['extension'];
        $localesDir = $extensionDir . '/locales';
        $locales = array();
        
        $directories = scandir($localesDir);
        if ($directories === false) {
            $this->err("The locales directory of extension '" . $this->options['extension'] . "' cannot be read.", true);    
        } else {
            foreach ($directories as $dir) {
                if ($dir[0] !== '.') {
                    // It is a language directory.
                    $locales[] = $dir;
                }
            }
        }
        
        foreach ($locales as $l) {
            $this->options['language'] = $l;
            $this->checkCompileInput();
            $this->actionCompile();
            
            $this->outVerbose("");
        }
        
    }
157076
function (inside, before, insert, root) {
			root = root || _.languages;
			var grammar = root[inside];
			var ret = {};
				
			for (var token in grammar) {
			
				if (grammar.hasOwnProperty(token)) {
					
					if (token == before) {
					
						for (var newToken in insert) {
						
							if (insert.hasOwnProperty(newToken)) {
								ret[newToken] = insert[newToken];
							}
						}
					}
					
					ret[token] = grammar[token];
				}
			}
			
			return root[inside] = ret;
		}
158703
public function setupRules()
    {
        $this->rules->addMany([
            'keyword' => [
                new Rule(new WordMatcher($this->_keywords, ['escape' => false, 'separated' => true]))
            ],

            'constant' => new Rule(new WordMatcher(['False', 'True', 'Nothing']), ['priority' => 3]),
            'comment'  => new Rule(new CommentMatcher(['--'], [['{-', '-}']]), ['priority' => 20]),

            'symbol.type' => new Rule(new RegexMatcher('/\b(_*[A-Z]\w*)\b/'), ['priority' => 1]),
            'symbol.function' => [
                new Rule(new RegexMatcher('/(_*[a-z]\w*)\s*::/')),
                new Rule(new RegexMatcher('/[;\n](_*[a-z]\w*).*?=/'))
            ],
            'operator.named' => new Rule(new RegexMatcher('/(`\w+`)/')),

            'string'   => CommonFeatures::strings(['single' => '\'', 'double' => '"']),

            'number'          => new Rule(new RegexMatcher('/\b(\d+(?>(?>\.|e[+-]?)\d+)?|0o[0-7]+|0x[0-9a-f])\b/i'), ['context' => ['!string', '!comment']]),
            'operator.escape' => new Rule(new RegexMatcher('/(\\[\\0\'|bnrtZ%_])/'), ['context' => ['string']]),
            'operator'        => new Rule(new RegexMatcher('/([^\r\n\s\w\"\'\`\[\]\(\)\{\}]+)/'), [
                'priority' => -1,
                'context'  => ['!comment', '!string']
            ])
        ]);
    }
475981
private function _rules($embedded = false)
    {
        $rules = clone $this->rules;
        if(is_bool($embedded)) {
            $rules->addMany(['language.'.$this->getIdentifier() => $this->getEnds($embedded)]);
        }

        foreach ($rules->all() as $rule) {
            yield $rule;
        }

        // todo: interface
        foreach ($this->getEmbedded() as $language) {
            foreach ($language instanceof GreedyLanguage ? $language->_rules(true) : $language->getEnds(true) as $rule) {
                yield $rule;
            }
        }
    }
709998
private static Language makeLanguage(File file, boolean isAdditional) throws IllegalAccessException, InstantiationException {
    Objects.requireNonNull(file, "file cannot be null");
    if (!file.getName().endsWith(".xml")) {
      throw new RuleFilenameException(file);
    }
    String[] parts = file.getName().split("-");
    boolean startsWithRules = parts[0].equals("rules");
    boolean secondPartHasCorrectLength = parts.length == 3 &&
            (parts[1].length() == "en".length() || parts[1].length() == "ast".length() || parts[1].length() == "en_US".length());
    if (!startsWithRules || !secondPartHasCorrectLength) {
      throw new RuleFilenameException(file);
    }
    //TODO: when the XML file is mergeable with
    // other rules (check this in the XML Rule Loader by using rules[@integrate='add']?),
    // subclass the existing language,
    //and adjust the settings if any are set in the rule file default configuration set

    Language newLanguage;
    if (Languages.isLanguageSupported(parts[1])) {
      Language baseLanguage = Languages.getLanguageForShortCode(parts[1]).getClass().newInstance();
      newLanguage = new ExtendedLanguage(baseLanguage, parts[2].replace(".xml", ""), file);
    } else {
      newLanguage = new Language() {
        @Override
        public Locale getLocale() {
          return new Locale(getShortCode());
        }

        @Override
        public Contributor[] getMaintainers() {
          return null;
        }

        @Override
        public String getShortCode() {
          if (parts[1].length() == 2) {
            return parts[1];
          }
          return parts[1].split("_")[0]; //en as in en_US
        }

        @Override
        public String[] getCountries() {
          if (parts[1].length() == 2) {
            return new String[]{""};
          }
          return new String[]{parts[1].split("_")[1]}; //US as in en_US
        }

        @Override
        public String getName() {
          return parts[2].replace(".xml", "");
        }

        @Override
        public List<Rule> getRelevantRules(ResourceBundle messages, UserConfig userConfig, Language motherTongue, List<Language> altLanguages) {
          return Collections.emptyList();
        }

        @Override
        public List<String> getRuleFileNames() {
          List<String> ruleFiles = new ArrayList<>();
          ruleFiles.add(file.getAbsolutePath());
          return ruleFiles;
        }

        @Override
        public boolean isExternal() {
          return isAdditional;
        }
      };
    }
    return newLanguage;
  }
978514
private function runMultiLanguage(): void
    {
        // check if multi-language is enabled
        if (!App::$Properties->get('multiLanguage')) {
            $this->language = App::$Properties->get('singleLanguage');
            return;
        }

        // check if domain-lang binding is enabled
        if (Any::isArray(App::$Properties->get('languageDomainAlias'))) {
            /** @var array $domainAlias */
            $domainAlias = App::$Properties->get('languageDomainAlias');
            if (Any::isArray($domainAlias) && !Str::likeEmpty($domainAlias[$this->getHost()])) {
                $this->language = $domainAlias[$this->getHost()];
            }
            return;
        }

        // try to find language in pathway
        foreach (App::$Properties->get('languages') as $lang) {
            if (Str::startsWith('/' . $lang, $this->getPathInfo())) {
                $this->language = $lang;
                $this->languageInPath = true;
            }
        }

        // try to find in ?lang get
        if (!$this->language && Arr::in($this->query->get('lang'), App::$Properties->get('languages'))) {
            $this->language = $this->query->get('lang');
        }

        // language still not defined?!
        if (!$this->language) {
            $this->setLanguageFromBrowser();
        }
    }
1004232
public function addImplicitExtension($rule, $extension)
    {
        $this->addExtension($rule, $extension);

        $this->implicitRules[] = studly_case($rule);
    }
1028983
public function setupRules()
    {
        $this->rules->addMany([
            'keyword' => new Rule(new WordMatcher([
                'ACCEPT', 'ACCESS', 'ADD', 'ADDRESS', 'ADVANCING', 'AFTER', 'ALL', 'ALPHABET',
                'ALPHABETIC(-(LOWER|UPPER))?', 'ALPHANUMERIC(-EDITED)?', 'ALSO', 'ALTER', 'ALTERNATE', 'AND', 'ANY',
                'APPLY', 'ARE', 'AREA', 'AREAS', 'ASCENDING', 'ASSIGN', 'AT', 'AUTHOR', 'BASIS', 'BEFORE', 'BEGINNING',
                'BINARY', 'BLANK', 'BLOCK', 'BOTTOM', 'BY', 'CALL', 'CANCEL', 'CBL', 'CHARACTER', 'CHARACTERS', 'CLASS',
                'CLOSE', 'CODE-SET', 'COLLATING', 'COMMA', 'COMMON', 'COMP(-[1-4])?', 'COMPUTATIONAL(-[1-4])?',
                'COMPUTE', 'CONFIGURATION', 'CONTAINS', 'CONTENT', 'CONTINUE', 'CONVERTING', 'COPY', 'CORR',
                'CORRESPONDING', 'COUNT', 'CURRENCY', 'DATA', 'DATE(-(COMPILED|WRITTEN))?', 'DAY-OF-WEEK', 'DAY',
                'DBCS', 'DEBUG-ITEM', 'DEBUGGING', 'DECIMAL-POINT', 'DECLARATIVES', 'DEGUGGING', 'DELETE', 'DELIMITED',
                'DELIMITER', 'DEPENDING', 'DESCENDING', 'DISPLAY(-1)?', 'DIVIDE', 'DIVISION', 'DOWN', 'DUPLICATES',
                'DYNAMIC', 'EBCDIC', 'EGCS', 'EJECT', 'ELSE',
                'END(-(ADD|CALL|COMPUTE|DELETE|DIVIDE|EVALUATE|IF|MULTIPLY|OF-PAGE|PERFORM|READ|RETURN|REWRITE|SEARCH|START|STRING|SUBTRACT|UNSTRING|WRITE))?',
                'ENDING', 'ENTER', 'ENTRY', 'ENVIRONMENT', 'EOP', 'EQUAL', 'ERROR', 'EVALUATE', 'EVERY', 'EXCEPTION',
                'EXIT', 'EXTEND', 'EXTERNAL', 'F', 'FALSE', 'FD', 'FILE(-CONTROL)?', 'FILLER', 'FIRST', 'FOOTING',
                'FOR', 'FROM', 'GIVING', 'GLOBAL', 'GO', 'GOBACK', 'GREATER', 'HIGH-VALUES?', 'I-O(-CONTROL)?', 'ID',
                'IDENTIFICATION', 'IF', 'IN', 'INDEX', 'INDEXED', 'INITIAL', 'INITIALIZE', 'INPUT', 'INPUT-OUTPUT',
                'INSERT', 'INSPECT', 'INSTALLATION', 'INTO', 'INVALID', 'IS', 'JUST', 'JUSTIFIED', 'KANJI', 'KEY',
                'LABEL', 'LEADING', 'LEFT', 'LENGTH', 'LESS', 'LINAGE(-COUNTER)?', 'LINE', 'LINES', 'LINKAGE', 'LIST',
                'LOCK', 'LOW-VALUES?', 'MAP', 'MEMORY', 'MERGE', 'MODE', 'MODULES', 'MORE-LABELS', 'MOVE', 'MULTIPLE',
                'MULTIPLY', 'NATIVE', 'NEGATIVE', 'NEXT', 'NO', 'NOLIST', 'NOMAP', 'NOSOURCE', 'NOT', 'NULL', 'NULLS',
                'NUMERIC(-EDITED)?', 'OBJECT-COMPUTER', 'OCCURS', 'OF', 'OFF', 'OMITTED', 'ON', 'OPEN', 'OPTIONAL',
                'OR', 'ORDER', 'ORGANIZATION', 'OTHER', 'OUTPUT', 'OVERFLOW', 'PACKED-DECIMAL', 'PADDING', 'PAGE',
                'PASSWORD', 'PERFORM', 'PIC', 'PICTURE', 'POINTER', 'POSITION', 'POSITIVE', 'PROCEDURE', 'PROCEDURES',
                'PROCEED', 'PROCESS', 'PROGRAM(-ID)?', 'QUOTE', 'QUOTES', 'RANDOM', 'READ', 'READY', 'RECORD',
                'RECORDING', 'RECORDS', 'REDEFINES', 'REEL', 'REFERENCE', 'RELATIVE', 'RELEASE', 'RELOAD', 'REMAINDER',
                'REMOVAL', 'RENAMES', 'REPLACE', 'REPLACING', 'RERUN', 'RESERVE', 'RESET', 'RETURN(-CODE)?REVERSED',
                'REWIND', 'REWRITE', 'RIGHT', 'ROUNDED', 'RUN', 'S', 'SAME', 'SD', 'SEARCH', 'SECTION', 'SECURITY',
                'SEGMENT-LIMIT', 'SELECT', 'SENTENCE', 'SEPARATE', 'SEQUENCE', 'SEQUENTIAL', 'SERVICE', 'SET',
                'SHIFT-(IN|OUT)', 'SIGN', 'SIZE', 'SKIP1', 'SKIP2', 'SKIP3',
                'SORT(-(CONTROL|CORE-SIZE|FILE-SIZE|MERGE|MESSAGE|MODE-SIZE|RETURN))?', 'SOURCE(-COMPUTER)?', 'SPACE',
                'SPACES', 'SPECIAL-NAMES', 'STANDARD(-[1-2])?', 'START', 'STATUS', 'STOP', 'STRING', 'SUBTRACT',
                'SUPPRESS', 'SYMBOLIC', 'SYNC', 'SYNCHRONIZED', 'TALLY', 'TALLYING', 'TAPE', 'TEST', 'THAN', 'THEN',
                'THROUGH', 'THRU', 'TIME', 'TIMES', 'TITLE', 'TO', 'TOP', 'TRACE', 'TRAILING', 'TRUE', 'U', 'UNIT',
                'UNSTRING', 'UNTIL', 'UP', 'UPON', 'USAGE', 'USE', 'USING', 'V', 'VALUE', 'VALUES', 'VARYING',
                'WHEN(-COMPILED)?', 'WITH', 'WORDS', 'WORKING-STORAGE', 'WRITE(-ONLY)?', 'ZERO(S|ES)?',
            ], ['case-sensitivity' => true, 'separated' => true, 'escape' => false])),
            'number'  => new Rule(new RegexMatcher('/([\+\-]?(?:[0-9]*[\.][0-9]+|[0-9]+))/')),
            'comment' => new Rule(new CommentMatcher(['*'])),
            'string'  => CommonFeatures::strings(['"', '\'']),
        ]);
    }
38159
public function setupRules()
    {
        $this->rules->addMany([
            'tag.open'  => [
                new OpenRule(new RegexMatcher('/(<[\w\.-]+)[:\/>:\s]/')),
                new CloseRule(new SubStringMatcher('>'), ['context' => ['!string', '!comment']]),
            ],
            'tag.close' => new Rule(new RegexMatcher('/(<\/' . self::IDENTIFIER . '>)/')),

            'symbol.tag' => new Rule(new RegexMatcher('/<\\/?' . self::IDENTIFIER . '/', [
                'name'      => Token::NAME,
                'namespace' => '$.namespace',
            ]), ['context' => ['tag', '!string']]),

            'number'  => new Rule(new RegexMatcher('/\s(-?(?:0[0-7]+|0[xX][0-9a-fA-F]+|0b[01]+|\d+(?:\.\d+)?))/')),
            'comment' => new Rule(new CommentMatcher(['#'])),
            'string'  => [
                CommonFeatures::strings(['single' => '\'', 'double' => '"'], ['context' => ['!comment', '!operator.escape']]),
                'path' => new Rule(new RegexMatcher('/\B(\/[^\s\)\(]*)/'))
            ],

            'call'    => new Rule(new RegexMatcher('/^\s*(\w+)/mi')),
            'variable'   => new Rule(new RegexMatcher('/%\{([\w-]+)\}/i'), ['context' => ['expression']]),

            'expression' => new Rule(new RegexMatcher('/(%\{.*?\})/i'), ['context' => ['string']]),
            'expression.regex' => [
                new Rule(new RegexMatcher('/(\[(?>[^\[\]]+|(?1))*\])/'), ['context' => ['string']]),
            ],

            'number.ip' => [
                new Rule(new RegexMatcher('/(\d{1,3}(\.\d{1,3}){3})/i'), ['context' => ['!string']])
            ],
            'constant' => new Rule(new WordMatcher(['On', 'Off', 'None', 'All', 'Any'])),

            'operator.escape' => new Rule(new RegexMatcher('/(\\\(?:\R|.|[0-7]{3}|x\x{2}))/s'), [
                'context' => ['!comment'],
                'priority' => 10
            ]),
            'operator.punctuation' => new Rule(new RegexMatcher('/([\(\){},;])/i')),
            'keyword.format' => new Rule(
                new RegexMatcher('/(%[\w%][-+#0]?(?:[0-9]+|\*)?(?:\.(?:[0-9]+|\*))?)/'), [
                    'context' => ['string']
                ]
            ),
        ]);
    }