Methods to handle locale selection and retrieve localized content when multi-language is enabled.

Returns an array of enabled locales. Result will be empty if multi-language has not been configured on the store.

List enabled locales
    "code": "en",
    "name": "English"
    "code": "fr",
    "name": "French"
    "code": "es",
    "name": "Spanish"

Sets a browser cookie and updates the user's session and cart to the selected locale.

In a multi-language setup, call the select() method to change settings used to retrieve all types of content (products, pages, etc.)

If a cart exists in the user's session, this method also updates the cart to reflect the user's locale preference

The store default or user-selected locale is used automatically when retrieving content with this library.

Retrieve localized content
  "name": "Producto de prueba"

Results will have the same shape as non-localized values, with localized fields overwriting default ones.

Returns the selected locale code. Defaults to the store's default locale.

Get selected locale
swell.locale.selected() // => es

In a multi-language setup, all methods available in this library will retrieve localized content according to the selected, fallback, or store's default locale (in that order).

When a customer account is created or updated in a storefront or during checkout, the selected locale will also be stored on the customer record and will be used to resolve localized content for email notifications and other offline communications.

See our Help Center for more details on multi-language setup.