Why are field-level translations not recommended for PortableText?

10 replies
Last updated: Jan 23, 2024
Hello! I am reading that the
field-level translations
is not recommended for content using
PortableText
. Has anyone tried / knows why this is the case?Source:
https://www.sanity.io/plugins/document-internationalization
AI Update

The recommendation against using field-level translations with Portable Text in Sanity is primarily due to attribute count concerns.

Why Field-Level Translation Objects Don't Work Well with Portable Text

When you use the object-based approach for field-level translations (where each language gets its own field like title.en, title.es, etc.), Portable Text content creates a massive number of attributes in your dataset.

Here's why: Portable Text is inherently complex. Each block, span, mark, annotation, and decorator creates its own attributes. When you multiply this by multiple languages using the object approach, you quickly hit Sanity's attribute limits.

For example, a simple Portable Text field might create attributes like:

  • content[].children[]
  • content[].markDefs[]
  • content[].style

With field-level objects for 3 languages, you'd get:

  • content.en[].children[]
  • content.es[].children[]
  • content.no[].children[]
  • (and so on for every nested property)

This exponentially increases your attribute usage with each additional language.

Better Alternatives

The document-internationalization plugin documentation explicitly recommends document-level translations for Portable Text content. This means:

  1. Separate documents per language - Each language version is its own document, linked via references
  2. Independent publishing - You can publish translations as they're ready
  3. No attribute explosion - Each document has its own set of attributes

The Array Exception

If you must use field-level translations with Portable Text, the internationalized-array plugin is a better option than objects, as it uses fewer attributes by storing the language identifier in the _key field rather than creating separate object properties for each language.

However, document-level translation remains the recommended approach for any content-heavy fields like Portable Text.

Show original thread
10 replies
That would be because it creates a massive number of attributes and will cause you issues as you generate content.
Thanks
user M
, so would it then follow that if a majority of a project’s components include the need for Rich Text with Portable Text, document level translation is really the best/only way forward?
Correct. I’d only ever use field level translation if there were one or two fields needing translation. Document level is the way to go.
Always helpful to get it validated from the source, thanks so much
user M
!
You’re very welcome!
Hopefully a quick follow up — is there a way to provide documents for translation to a third party? I was reading about the Transifex plugin (my client uses TransPerfect so this won’t work).
Yes, but we don’t currently have a plugin for TransPerfect. You could take a look at the existing plugins and use them as guidance for building out your own, though.
Got it — so by plugin only, at the moment?
You could also create a document action or anything that sends the JSON of a document to whatever service you’re using. Your service would need to to be configured to write content back to your dataset as well.
Ahh right right. THANK YOU! Appreciate your time.

Sanity – Build the way you think, not the way your CMS thinks

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.

Was this answer helpful?