Function detectLang

  • Get browser/nodejs language

    Returns string

    BCP 47 tags of the browser/nodejs language

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

    Type Parameters

    • T extends string

    Parameters

    • langs: readonly T[]

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

    Returns T | null

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

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

    • langs: readonly string[]

    Returns string | null