Picture of Auto-Select Language & Currency from Browser Headers

Auto-Select Language & Currency from Browser Headers

This feature automatically preselects a visitor’s language and currency based on their browser’s Accept-Language header (e.g., en-US,en;q=0.9,es;q=0.8). You can map a default currency to each language in Admin (for example: en-GB → GBP, en-US → USD, anything else → EUR—or any mapping you configure).

Selections are stored in a guest cookie to avoid creating guest users just to hold preferences. When a guest registers or is otherwise promoted to a customer, their language, currency, and tax preferences are transferred to their account.

You have full control via settings:

  • Turn the feature on/off.

  • Choose whether to use the top language from the header or apply a fallback.

  • Enable auto-detect separately for language and currency.

Compatibility and resilience:

  • Works with both LanguageCulture (e.g., en-GB) and UniqueSeoCode (e.g., en).

  • Hardened to handle cookie, editor/multipart, and null-customer edge cases gracefully.


Key Settings

All settings live under Customer Settings › Guest user locale settings.

  • Automatic language/currency selection (default: disabled)
    Master toggle. Enables the behavior described below.

  • Use top language match from Accept-Language header (default: enabled)

    • Enabled: Pick the first language listed in the header (ignore q= weights).

    • Disabled: Fall back to the next listed language or your predefined default.

  • Automatically detect and set language (default: enabled)
    Controls whether language is auto-set based on the header and available languages.

  • Automatically detect and set currency (default: enabled)
    Controls whether currency is auto-set using your Default currency per language mappings.

Admin mapping: Each Language has a Default currency field. This drives which currency is selected when that language is chosen.

Cookie: Guest selections are stored in INF.CustomerContext with:

  • lang = languageId

  • cur = currencyId

  • tax = tax display type
    On registration, the cookie is removed and its values are migrated to the customer.


Use Cases

  • Regional defaults without geolocation:
    A multilingual, multi-currency storefront wants: en-US → USD, en-GB → GBP, everything else → EUR. Map these in Admin and let the header do the heavy lifting.

  • Frictionless guest browsing:
    First-time visitors see the right language/currency immediately, without creating an account.

  • SEO & locale consistency:
    Match LanguageCulture when available; fall back to UniqueSeoCode (e.g., en) if needed.


Step-by-Step Implementation Guide

  1. Enable the feature

    1. Go to Customer Settings › Guest user locale settings.

    2. Enable Automatic language/currency selection.

    3. (Optional) Adjust sub-settings:

      • Use top language match (recommended: enabled)

      • Automatically detect and set language

      • Automatically detect and set currency

  2. Map a default currency to each language

    1. Go to Admin › Languages.

    2. For each language you offer, set Default currency.

      • Example mappings (purely illustrative):

        • en-US → USD

        • en-GB → GBP

        • fr-FR, es-ES, etc. → EUR (or any currency you choose)


Behavior & Edge Cases (How it works)

  • Matching order:

    1. LanguageCulture exact match → 2) UniqueSeoCode match → 3) Partial language match → 4) Configured default.

  • Case-insensitive: en-US, EN-us, en-us are treated the same.

  • Duplicates in header: Deterministic; the first acceptable match (respecting the Top language setting) is used.

  • Invalid/wildcard values (e.g., *, en-UK): falls back to partial/SEO code matches, then your default.

  • No header present: falls back to your configured default language/currency.

  • Performance: language lookups use a fast in-memory map (hash-map-style) to keep overhead ~O(1).

  • Caching: output caching respects cookie-based selections to avoid creating guest users for preference storage.

  • Scope: this feature uses browser headers, not IP geolocation.

Incomplete
Alternate Search Terms

auto detect language and currency, browser language to site language, Accept-Language header settings, map currency to language, set default currency per language, auto select storefront language, header-based locale detection, guest cookie language currency, enable language auto selection, fallback language and currency settings