Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
fix(db-mongodb): localization transforms on nested localized fields (#14600)
Fixes an issue where nested `localized: true` fields were not adhering
to the correct data shape if a parent was already localized. This change
works with the `compatibility.allowLocalizedWithinLocalized` flag set
and not set. Before it would only work if you had the compatibility flag
set to true, which is not the default.
The issue surfaces when querying with `locale: "all"`.
Example:
```ts
fields: [{
name: 'localizedBlocks',
type: 'blocks',
blocks: [
{
slug: 'nestedBlock',
fields: [
{
name: 'nestedArray',
type: 'array',
fields: [
{
name: 'item',
type: 'text',
},
],
localized: true, // <-- this
},
],
},
],
localized: true, // <-- and this
}],
```
When transforming the outgoing data it would not include everything
because it would incorrectly attempt to access data by locale on nested
data instead of just the field name.
#### Before (incorrect)
```ts
localizedBlocks: {
en: [
{
blockType: 'nestedBlock',
nestedArray: [] // <-- missing
}
]
}
```
#### After (correct)
```ts
localizedBlocks: {
en: [
{
blockType: 'nestedBlock',
nestedArray: [ // <-- included
{
id: '69162b9cecdd3484a55e196b',
item: 'EN Nested',
},
],
},
]
}
``` J
Jarrod Flesch committed
6070d8d7529829768c91c2d45f884a644c902819
Parent: e1f07ff
Committed by GitHub <noreply@github.com>
on 11/13/2025, 7:09:38 PM