@area2-ai/a2-node-keystroke-package
Version:
## Description
15 lines (14 loc) • 720 B
TypeScript
/**
* Formats the user's language and country code based on the browser's language settings.
*
* @returns {string} A formatted language code in the form of `language-country` (e.g., `en-US`).
*
* ### Functionality:
* - Retrieves the user's browser language using `navigator.language`.
* - Splits the language string into a language code (e.g., `en`) and a country code (e.g., `US`).
* - Checks if the country code is valid (i.e., not numeric):
* - If valid, returns the original `language-country` format.
* - If invalid or missing, assigns a default country code based on the language.
* - Returns the final formatted language string.
*/
export declare const formatLanguage: () => string;