docs: fix locale option passed to query (#14472)

This commit is contained in:
Shahed Nasser
2026-01-06 18:59:44 +02:00
committed by GitHub
parent 893da93feb
commit 76ff8dcca8
7 changed files with 119 additions and 101 deletions
@@ -856,19 +856,21 @@ This will retrieve all brands that are linked to at least one product.
]}
/>
To retrieve localized data for data models that have translations, pass an `options.locale` property to the first parameter of the `query.index` method:
To retrieve localized data for data models that have translations, pass a `locale` property in the second parameter object of the `query.index` method.
```ts highlights={[["5", "locale", "Pass the locale to retrieve localized data."]]}
const { data: products } = await query.index({
entity: "product",
fields: ["id", "title", "description"],
options: {
locale: "fr-FR",
```ts highlights={[["7", "locale", "Pass the locale to retrieve localized data."]]}
const { data: products } = await query.index(
{
entity: "product",
fields: ["id", "title", "description"],
},
})
{
locale: "fr-FR",
}
)
```
The `options.locale` property is a string representing the locale code following the [IETF BCP 47 standard](https://gist.github.com/typpo/b2b828a35e683b9bf8db91b5404f1bd1).
The `locale` property is a string representing the locale code following the [IETF BCP 47 standard](https://gist.github.com/typpo/b2b828a35e683b9bf8db91b5404f1bd1).
The returned products will have their `title` and `description` properties in French (`fr-FR`), if translations are available.
@@ -869,19 +869,21 @@ In the example above, you retrieve only deleted posts by enabling the `withDelet
]}
/>
To retrieve localized data for data models that have translations, pass an `options.locale` property to the first parameter of the `query.graph` method.
To retrieve localized data for data models that have translations, pass a `locale` property in the second parameter object of the `query.graph` method.
<CodeTabs group="query">
<CodeTab label="query.graph" value="query.graph">
```ts highlights={[["5", "locale", "Pass the locale to retrieve localized data."]]}
const { data: products } = await query.graph({
entity: "product",
fields: ["id", "title", "description"],
options: {
locale: "fr-FR",
```ts highlights={[["7", "locale", "Pass the locale to retrieve localized data."]]}
const { data: products } = await query.graph(
{
entity: "product",
fields: ["id", "title", "description"],
},
})
{
locale: "fr-FR",
}
)
```
</CodeTab>
@@ -900,7 +902,7 @@ const { data: products } = useQueryGraphStep({
</CodeTab>
</CodeTabs>
The `options.locale` property is a string representing the locale code following the [IETF BCP 47 standard](https://gist.github.com/typpo/b2b828a35e683b9bf8db91b5404f1bd1).
The `locale` property is a string representing the locale code following the [IETF BCP 47 standard](https://gist.github.com/typpo/b2b828a35e683b9bf8db91b5404f1bd1).
The returned products will have their `title` and `description` properties in French (`fr-FR`), if translations are available.