Namespace: Context:getBrowserLanguage

Context:getBrowserLanguage

Source:

Methods

getBrowserLanguage(fallbackLanguageopt, nullable) → {String|null}

Evaluates all available browser languages and tries to return the preferred one.

Since browsers could not agree on a uniform way to return language values yet, the returned language will always be "lowercaselanguage-UPPERCASECOUNTRY" or just "lowercaselanguage", if we have no country.

Parameters:
Name Type Attributes Default Description
fallbackLanguage String <optional>
<nullable>
null

fallback value to return if no language could be evaluated

Source:
See:
Returns:
the preferred browser language if available, null if no language can be detected and no fallback has been defined
Type
String | null
Example
getBrowserLanguage()
=> "en"