Skip to content

getLanguage

The getLanguage function returns the user's preferred browser language.

Syntax

typescript
getLanguage(): string;

Parameters

NameTypeDescription
This function does not take any parameters

Returns

NameTypeDescription
stringPreferred language code (e.g., "en-US")

Examples

typescript
getLanguage();
// => "en-US"

Notes

  • Useful for internationalization and content adaptation.
  • May return only the primary language code (e.g., "en").

References

Released under the MIT License.