How to use the @phensley/language-tag.LanguageTagField.LANGUAGE function in @phensley/language-tag

To help you get started, we’ve selected a few @phensley/language-tag 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 / locale / src / resolver.ts View on Github external
const fastTag = (real: LanguageTag): FastTag => {
  // Hack to get fast access to internal core fields without exposing them.
  const fake = (real as any) as FakeLanguageTag;

  // The fast tag is used for indexing purposes. Since a field may be
  // undefined, and we don't want to use its string representation of
  // the undefined value (e.g. 'und', 'Zzzz', etc), we use the field's
  // index number to represent undefined.
  const language = fake.core[Tag.LANGUAGE];
  const script = fake.core[Tag.SCRIPT];
  const region = fake.core[Tag.REGION];
  return [
    language || Tag.LANGUAGE,
    script || Tag.SCRIPT,
    region || Tag.REGION
  ];
};
github phensley / cldr-engine / packages / locale / src / resolver.ts View on Github external
const returnTag = (real: LanguageTag, fast: FastTag): LanguageTag => {
  const language = fast[Tag.LANGUAGE];
  const script = fast[Tag.SCRIPT];
  const region = fast[Tag.REGION];

  return new LanguageTag(
    typeof language === 'number' ? undefined : language,
    typeof script === 'number' ? undefined : script,
    typeof region === 'number' ? undefined : region,
    real.variant(),
    real.extensions(),
    real.privateUse()
  );
};
github phensley / cldr-engine / packages / locale / src / resolver.ts View on Github external
const setFields = (src: FastTag, dst: FastTag, flags: number): void => {
  dst[Tag.LANGUAGE] = (flags & F.LANGUAGE) === 0 ? Tag.LANGUAGE : src[Tag.LANGUAGE];
  dst[Tag.SCRIPT] = (flags & F.SCRIPT) === 0 ? Tag.SCRIPT : src[Tag.SCRIPT];
  dst[Tag.REGION] = (flags & F.REGION) === 0 ? Tag.REGION : src[Tag.REGION];
};

@phensley/language-tag

Parsing and construction of BCP 47 language tags

Apache-2.0
Latest version published 2 months ago

Package Health Score

62 / 100
Full package analysis

Similar packages