Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 831 Bytes

tryQueryLocale.md

File metadata and controls

24 lines (15 loc) · 831 Bytes

Function: tryQueryLocale()

try to get the locale from the query

Signature

export function tryQueryLocale(request: IncomingMessage, options: QueryOptions = {}): Intl.Locale | null

Parameters

Name Type Description
request IncomingMessage the request
options QueryOptions The query options, lang option is en-US as default, name option is locale as default. (optional, default: {})

Returns

Intl.Locale | null — The locale that resolved from query. if the language in the query, that is not a well-formed BCP 47 language tag, return null.

Tags

  • @description — Unlike getQueryLocale, this function does not throw an error if the locale cannot be obtained, this function returns null.