
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI understand you're having trouble querying a localized bodyPortableText field where you need to combine a language parameter, coalescing, and expanding the array content.
The key is understanding that with localized arrays (like when using the internationalized-array plugin), you need to:
value property[]coalesce() for fallbacksHere's the pattern:
*[_type == "yourDocType"] {
title,
"body": coalesce(
bodyPortableText[_key == $language][0].value[],
bodyPortableText[_key == $baseLanguage][0].value[],
[]
)
}Breaking this down:
bodyPortableText[_key == $language][0] - Filters the localized array to your language and gets the first match.value[] - The crucial part! The [] at the end expands the Portable Text array content (all the blocks, marks, inline objects, etc.)coalesce(...) - Tries your requested language first, falls back to base language, then empty arrayWithout the []: You'd get the Portable Text as a nested structure rather than expanded content.
With the []: You get the actual block content that you can render.
If you need to transform the Portable Text blocks themselves, you can project inside the expansion:
"body": coalesce(
bodyPortableText[_key == $language][0].value[]{
...,
_type == "image" => {
...,
asset->
}
},
bodyPortableText[_key == $baseLanguage][0].value[],
[]
)This pattern is covered in the Sanity localization documentation, specifically in the "Querying localized arrays with GROQ" section. The same principles apply whether you're working with simple strings or complex Portable Text content - the [] expansion is what makes it work for arrays within arrays.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store