How to use the @phensley/cldr-core.LanguageResolver.resolve function in @phensley/cldr-core

To help you get started, we’ve selected a few @phensley/cldr-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phensley / cldr-engine / packages / cldr-compiler / src / rbnf / collector.ts View on Github external
Object.keys(NumberingSystems).forEach(k => {
      const sys = NumberingSystems[k];
      if (sys._type !== 'algorithmic') {
        return;
      }
      if (sys._rules.indexOf('/SpelloutRules') === -1) {
        return;
      }
      const parts = sys._rules.split('/');
      const tag = LanguageResolver.resolve(parts[0]);
      const id = `${tag.language()}-${tag.script()}`;

      if (!this.core.includes(id)) {
        this.core.push(id);
      }

      // Map numbering systems to a spellout locale id
      const set = this.systems.get(id) || [];
      set.push(k);
      this.systems.set(id, set);
    });
github phensley / cldr-engine / packages / cldr-compiler / src / rbnf / collector.ts View on Github external
const res: Map = new Map();

    const ids: string[] = [];
    for (const file of files) {
      const p = path.join(dir, file);
      const data = JSON.parse(fs.readFileSync(p, { encoding: 'utf-8' })) as JSONRoot;
      if (!data.SpelloutRules && !data.OrdinalRules) {
        continue;
      }

      const { name } = path.parse(file);
      let id = name;
      if (name !== 'root') {
        // compact each tag to language-script with region if specified
        const tag = parseLanguageTag(name);
        const max = LanguageResolver.resolve(name);
        id = `${max.language()}-${max.script()}`;
        if (tag.hasRegion()) {
          id = `${id}-${max.region()}`;
        }
      }
      res.set(id, data);
      ids.push(id);
    }

    res.forEach((_, id) => this.populate(res, id));

    // Fill in the locales that have no RBNF mapping.
    for (const locale of availableLocales()) {
      const { tag } = locale;
      const id = `${tag.language()}-${tag.script()}`;
      if (res.has(id)) {
github phensley / cldr-engine / packages / cldr-compiler / src / cli / generator / code / systems.ts View on Github external
Object.keys(supp.NumberingSystems).forEach(k => {
    const o = supp.NumberingSystems[k];
    if (o._type === 'numeric') {
      const v: string[] = Array.from(o._digits);
      numeric += `  ${k}: [${escape(increasing(v) ? v.slice(0, 1) : v)}],\n`;
    } else if (o._type === 'algorithmic') {
      const v = o._rules;
      let parts = ['root', v];
      if (v.indexOf('/SpelloutRules') !== -1) {
        const tmp = v.split('/');
        const tag = LanguageResolver.resolve(tmp[0]);
        const id = `${tag.language()}-${tag.script()}`;
        parts = [id, tmp[2]];
      }
      algorithmic += `  ${k}: [${parts.map(p => `'${p}'`).join(', ')}],\n`;
    }
  });
github phensley / cldr-engine / packages / cldr-compiler / src / cli / compiler / util.ts View on Github external
const getLocale = (id: string): Locale => ({ id, tag: LanguageResolver.resolve(id) });