# withLocale

Give React component access to `defaultLocale`, `locale`, and `siteLocales`.

> Ensure `withLocale(Component)` is rendered within [`createPage([...connectArgs])(Page, [reducers])`](https://traveloka.gitbook.io/soya-next/api/create-page) hierarchy.

## Returns

*(Function)*: A higher order React component class that passes `defaultLocale`, `locale`, and `siteLocales` to the component below.

## Examples

```javascript
import { withLocale } from 'soya-next/i18n';

export default withLocale(({
  locale,
  defaultLocale,
  siteLocales,
}) => (
  <div>
    <div>Current locale is {locale}</div>
    <div>Default locale is {defaultLocale}</div>
    <div>Supported site locales are {siteLocales.join(', ')}</div>
  </div>
));
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://traveloka.gitbook.io/soya-next/api/with-locale.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
