Function detectLang

  • Get browser/nodejs language

    Returns

    BCP 47 tags of the browser/nodejs language

    Returns string

  • Get browser/nodejs language that matches the given language tags

    Returns

    The first language tag that matches the browser/nodejs language, or null if no match

    Example

    detectLang(["en", "zh-CN"]) || "zh-TW"
    

    Parameters

    • langs: readonly string[]

      The language tags to match (BCP 47 tags and sub-tags are supported)

    Returns string | null