updateLocaleSettings()
Updates the language and/or country settings. This sets an explicit user preference that takes priority over automatic locale detection.
Signature
await window.FairShareSDK.updateLocaleSettings(settings);
Parameters
| Parameter | Type | Description |
|---|---|---|
settings | object | Locale settings object |
Settings Object:
| Property | Type | Required | Description |
|---|---|---|---|
language | string | No | Language code (e.g., "en", "es") |
country | string | No | Country code (e.g., "US", "CA") |
At least one of language or country must be provided.
Locale Priority
When you call updateLocaleSettings(), it sets an explicit user preference that takes the highest priority:
| Priority | Source |
|---|---|
| 1 (highest) | Explicit user setting (this function) |
| 2 | IP Geolocation (automatic) |
| 3 | Company default locale |
| 4 (lowest) | Alphabetical fallback |
Examples
Update Both Language and Country
await window.FairShareSDK.updateLocaleSettings({ language: "es", country: "MX", });
Update Country Only
// Language stays the same, only country changes await window.FairShareSDK.updateLocaleSettings({ country: "CA", });
Update Language Only
// Country stays the same, only language changes await window.FairShareSDK.updateLocaleSettings({ language: "fr", });
When to Use
- User selects a different country from a dropdown
- User changes language preference in your UI
- Override automatic detection when you know the user's preference
When NOT to Use
- First-time visitors — Let automatic IP geolocation handle it
- Default shop settings — Configure in admin dashboard instead
Related
- Settings — Settings section overview
- getCountryCode — Get current country
- getLanguage — Get current language