# Localization

Source: https://developers.swell.is/frontend-api/localization

**Swell.js:**

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

### List enabled locales

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

**List enabled locales**

**swell.js**

```javascript
await swell.locale.list()
```

**swell.js** `Example result`

```javascript
[
  {
    "code": "en",
    "name": "English"
  },
  {
    "code": "fr",
    "name": "French"
  },
  {
    "code": "es",
    "name": "Spanish"
  }
]
```

### Select a locale

*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

### Retrieve localized content

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

**Retrieve localized content**

**swell.js**

```javascript
await swell.locale.select('es') // optional

await swell.products.list()
```

**swell.js** `Example result`

```javascript
{
  ...
  "name": "Producto de prueba"
  ...
}
```

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

### Get the selected locale

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

**Get selected locale**

**swell.js**

```javascript
swell.locale.selected() // => es
```

### Multi-language content

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.

**GraphQL:**

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

### List enabled locales

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

The parameters for this query are `_locale` and `_currency`.

**List enabled locales**

**GraphQL**

```graphql
query getStoreLocales {
  storeSettings(_locale: "en-US") {
    store {
      locale
      locales {
        name
        code
        fallback
      }
    }
  }
}
```
