Connect Sanity
Import Sanity documents into transglot and write reviewed translations back into each field's target-language key.
| Direction | Two-way |
| Imported | The source-language key of each mapped field, on published documents of the types you choose |
| Written back | The target-language keys of the same fields. The source-language key is never written |
| Sync | Sync from CMS |
| Plan | Starter and above |
Before you start
- Your translatable fields must use field-level localization: an object keyed by language, such as
{ en: "…", fr: "…" }(thelocaleStringandlocaleTextpattern). 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.
| Field | What to enter |
|---|---|
| Project ID | Your Sanity project ID |
| Dataset | The dataset name, for example production |
| API version | A dated version such as v2021-06-07. Leave blank for the default |
| API token | The token you created |
| Content types | Document type names, comma separated |
| Translatable fields | Field names, comma separated |
| Publish these locales | The 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.