@metreeca/core - v0.10.0
    Preparing search index...

    Module language

    BCP 47 language tags and RFC 4647 basic language ranges.

    Language Tags

    Confirm that a value carries a well-formed language tag before handing it to an API that expects one:

    import { isTag } from "@metreeca/core/language";

    if (isTag(value)) {
    // value is typed as Tag
    }

    Basic Language Ranges

    Confirm in the same way that a value carries a well-formed basic language range, wildcard included:

    import { isTagRange } from "@metreeca/core/language";

    if (isTagRange(value)) {
    // value is typed as TagRange
    }

    Matching

    Select the content whose language answers a request, testing a tag against the ranges a client accepts:

    import { matchTag } from "@metreeca/core/language";

    matchTag("de-CH", "de"); // true - Swiss German matches German range

    Naming

    Present a tag to readers as the name of the language it identifies, in a language they understand:

    import { nameTag } from "@metreeca/core/language";

    nameTag("zh-Hans"); // "Simplified Chinese" - named in English by default
    nameTag("zh-Hans", "it"); // "cinese semplificato" - named in Italian

    Variables

    TagPattern

    Regular expression matching BCP 47 language tags.

    TagRangePattern

    Regular expression matching RFC 4647 basic language ranges.

    Type Aliases

    Tag

    Language tag as defined by BCP 47/RFC 5646 § 2.1.

    TagRange

    Basic language range as defined by RFC 4647 § 2.1.

    Functions

    isTag

    Checks if a value is a valid language tag.

    isTagRange

    Checks if a value is a valid basic language range.

    matchTag

    Checks if a language tag matches a basic language range.

    nameTag

    Names the language identified by a language tag.