Content platforms

Connect Sanity

Import Sanity documents into transglot and write reviewed translations back into each field's target-language key.

DirectionTwo-way
ImportedThe source-language key of each mapped field, on published documents of the types you choose
Written backThe target-language keys of the same fields. The source-language key is never written
SyncSync from CMS
PlanStarter and above

Before you start

  • Your translatable fields must use field-level localization: an object keyed by language, such as { en: "…", fr: "…" } (the localeString and localeText pattern). A plain string field has no per-language keys to read or write.
  • The language keys in those objects must match the language codes in your transglot project.
  • Create an API token with write access in your Sanity project's API settings.

Connect

Open your project's settings, choose CMS, and pick Sanity in the CMS list.

FieldWhat to enter
Project IDYour Sanity project ID
DatasetThe dataset name, for example production
API versionA dated version such as v2021-06-07. Leave blank for the default
API tokenThe token you created
Content typesDocument type names, comma separated
Translatable fieldsField names, comma separated
Publish these localesThe target languages to write back

Select Connect, then Test connection. A successful test names the project and dataset.

What gets imported

transglot reads published documents only; drafts are not imported. For each mapped field it reads the value under your project's source language key.

Localized Portable Text fields (an object keyed by language whose values are block arrays) are supported. Each one is imported as a single string per field, with markers that keep the block structure.

How translations are written back

transglot patches only the target-language keys of each mapped field (for example title.fr) on the published document. The source-language key and every other language are left as they are.

For a Portable Text field, transglot rebuilds the target-language blocks from a copy of the source blocks, with the reviewed text placed back in. If a block's translation cannot be placed back safely, that block keeps the source text, so the field always stays valid Portable Text.

Troubleshooting

  • ... the credentials were rejected. The token is wrong, revoked, or has no write access.
  • ... the project or dataset was not found, check the settings. Check Project ID and Dataset.
  • A field never appears as a key: check it uses the field-level localization pattern and has a value under your source language key on a published document.

On this page