Last updated

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

ParameterTypeDescription
settingsobjectLocale settings object

Settings Object:

PropertyTypeRequiredDescription
languagestringNoLanguage code (e.g., "en", "es")
countrystringNoCountry 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:

PrioritySource
1 (highest)Explicit user setting (this function)
2IP Geolocation (automatic)
3Company 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