@phensley/language-tag
TypeScript icon, indicating that this package has built-in type declarations

1.8.1 • Public • Published

@phensley/language-tag

@phensley/language-tag min+gzip

Implements BCP 47 language tag parsing and construction.

Installation

NPM:

npm install --save @phensley/language-tag

Yarn:

yarn add @phensley/language-tag

Examples

const IDS = ['en', 'es', 'es-419', 'und-AR', 'und-Hant', 'iw', 'i-klingon'];
for (const id of IDS) {
  const tag = parseLanguageTag(id);
  console.log(`${tag.compact().padStart(10)}  ${tag.expanded()}`);
}
        en  en-Zzzz-ZZ
        es  es-Zzzz-ZZ
    es-419  es-Zzzz-419
    und-AR  und-Zzzz-AR
  und-Hant  und-Hant-ZZ
        iw  iw-Zzzz-ZZ
       tlh  tlh-Zzzz-ZZ
const t = new LanguageTag(undefined, 'latn', 'us', 'PoSiX', {
  u: ['ca-gregory']
});
console.log(t.expanded());
und-Latn-US-posix-u-ca-gregory

/@phensley/language-tag/

    Package Sidebar

    Install

    npm i @phensley/language-tag

    Weekly Downloads

    2,036

    Version

    1.8.1

    License

    Apache-2.0

    Unpacked Size

    137 kB

    Total Files

    39

    Last publish

    Collaborators

    • phensley