getLanguage()
Gets the current language code.
Signature
const language = window.FairShareSDK.getLanguage();
Returns
string — The current language code (e.g., "en", "es", "fr").
How Language is Determined
The language code is determined using the following priority:
- Explicit user setting — Set via
updateLocaleSettings() - Company default language — Configured in shop settings
Language is paired with the detected country to form the full locale (e.g., "en_CA" for English in Canada).
Example
const language = window.FairShareSDK.getLanguage(); console.log('Current language:', language); // e.g., "en"
Related
- Settings Overview — How locale detection works
- Language — Language selector component
- updateLocaleSettings — Update locale settings
- getCountryCode — Get current country code