iya-sts
    Preparing search index...

    Class export=

    Tags, the order of preferences, negotiation and the chooser. A static utility class; it holds no state.

    Index
    CHOOSER_ACTION: "/authn/language" = CHOOSER_ACTION

    The chooser endpoint the chooser's form posts to.

    ROW_CSS: string = ...

    The collapsed row's CSS.

    SOURCE: "en" = SOURCE

    The catalog every chain ends in.

    • Reads an Accept-Language value — or a preferredLanguage, which has the same syntax — into tags, best first. A q=0 tag and the wildcard are left out; a tag that is not well-formed is skipped.

      Parameters

      • value: unknown

        the header or attribute value

      Returns string[]

      canonical tags, best first

    • Canonicalises a language tag, or answers '' for one that is not well-formed (RFC 5646). tl becomes fil, iw becomes he, and case is normalised.

      Parameters

      • tag: unknown

        the tag as given

      Returns string

      the canonical tag, or ''

    • Takes every catalog of a catalogs.json index apart, skipping one Intl.Locale refuses (the server's loader logs that; a browser cannot).

      Parameters

      • catalogs: { tag: string }[]

        the index's catalogs

      Returns TagParts[]

      their parts, in order

    • Returns the catalogs that answer one tag, most specific first and English last: a regional overlay naming the tag's region, then the base catalog of its language and script.

      Parameters

      • tag: string

        a canonical tag

      • catalogs: TagParts[]

        every catalog's parts, in catalogs.json's order

      Returns { chain: string[]; direction: "ltr" | "rtl"; matched: boolean }

      the chain, which ends in English; matched says whether anything before English answered, or English itself did

    • Draws the language chooser: a form posting to the chooser endpoint, the offered locales by their own names, and a submit button. A static surface's runtime sends the same form as a request (WebI18n.wireChooser()) and draws the page again; a server-drawn page posts it.

      Parameters

      • t: ChooserTranslator

        the page's translator

      • offered: OfferedLocale[]

        the locales the chooser offers, each with its endonym

      • catalogs: TagParts[]

        every catalog's parts, for which offered locale the page is read in

      • returnTo: string

        the path to come back to; held to a local one

      Returns string

      the chooser as HTML

    • Escapes text for HTML, as Html.esc() does.

      Parameters

      • value: unknown

        anything

      Returns string

      the escaped text

    • Negotiates a list of preferences, best first, against the catalogs: the first one a catalog answers wins; when none does, the last resort does, and English when that answers nothing either.

      Parameters

      • preferences: string[]

        tags, best first

      • lastResort: string

        the tag to use when no preference is answered (the locale policy's default)

      • catalogs: TagParts[]

        every catalog's parts, in catalogs.json's order

      Returns Negotiated

      the locale, its catalog chain and its direction

    • Takes a tag apart: language, script and region, the region it NAMES, and its text direction. Throws on a tag Intl.Locale refuses.

      Parameters

      • tag: string

        a canonical tag

      Returns TagParts

      the parts

    • Lists a page's language preferences, best first, in #539's order — everything but the locale policy's default, which is the last resort a caller hands negotiate().

      Parameters

      • input: PreferenceInputs

        what the page's language is chosen from

      Returns string[]

      canonical tags, best first, each once

    • Wraps a chooser's form in the collapsed row.

      Parameters

      • labelHtml: string

        the translated Language, as HTML

      • current: OfferedLocale

        the offered locale the page is read in, or undefined

      • formHtml: string

        the chooser's form

      Returns string

      the row's HTML

    • Holds a return path to a local path: one that starts with a single /, names no scheme or host, and carries no control character or backslash. Anything else is /.

      Parameters

      • value: unknown

        the path the chooser posted

      Returns string

      a safe local path

    • Reads an OpenID Connect ui_locales value: a space-separated list of tags, best first.

      Parameters

      • value: unknown

        the parameter

      Returns string[]

      canonical tags, best first