Connect Contentful
Import Contentful entries into transglot and publish reviewed translations back into each entry's localized fields.
| Direction | Two-way |
| Imported | The source-locale value of the fields you map, on the content types you choose |
| Written back | Each entry's target-locale field slots. The source locale is never written |
| Sync | Sync from CMS, or a signed webhook to the Inbound URL |
| Plan | Starter and above |
Before you start
- In Contentful, mark the fields you want translated as localized and add your target locales to the space.
- Make sure the Contentful locale codes match the language codes in your transglot project. transglot reads the locale whose code is your project's source language, and writes each target language under its own code.
- Create a Content Management token in your Contentful settings. It needs read and write access to the space.
Connect
Open your project's settings, choose CMS, and pick Contentful in the CMS list.
| Field | What to enter |
|---|---|
| Space ID | Your space ID, from your Contentful space settings |
| Environment | The environment to use. Leave blank for master |
| Content Management token | The token you created (it starts with CFPAT-) |
| Content types | Content type IDs, comma separated, for example blogPost, landingPage |
| Translatable fields | Field IDs, comma separated, for example title, body |
| Publish these locales | The target locales to write back |
Select Connect, then Test connection. A successful test names the space it reached. The test also checks that the environment exists.
What gets imported
For each entry of each content type, transglot reads the source-locale value of every mapped field. Only fields whose value is a plain string are imported; a field with another kind of value (Rich Text, a reference, a number) is skipped. When the entry has a title field, its value becomes the description on each of the entry's keys.
How translations are written back
transglot reads the entry's current version, sets the target-locale slot of each mapped field, and saves the entry with Contentful's version check. Every other field and locale is kept as it was.
transglot saves the translations to the entry, but it does not run Contentful's publish action. Publish the entry in Contentful when you want the translations live.
Sync on content change
Once connected, the CMS page shows a Sync on content change card with an Inbound URL. A POST to that URL starts a sync without anyone pressing Sync from CMS. The CMS page suggests triggering it on Entry.publish.
transglot accepts the request only when it is signed with the inbound signing secret shown once when you first connected:
X-Transglot-Timestamp: the current Unix time in seconds. A timestamp more than five minutes away from transglot's clock is refused.X-Transglot-Signature:sha256=followed by the hex HMAC-SHA256 of the timestamp, a full stop, and the raw request body, keyed with the secret. This is the same scheme as transglot's outbound webhooks (Verify signatures).
To sync only the entries that changed, send a body that names them:
{ "entries": [ { "type": "blogPost", "id": "6xRkQ2pZ" } ] }The type is the content type ID and the id is the entry ID. A body that names no entries at all runs a full sync. A body with an entries list that holds no usable entry is accepted and does nothing.
Troubleshooting
Invalid signature.The request was unsigned, signed with an old secret, or its timestamp was outside the five-minute window. If you no longer have the secret, select Rotate signing secret and update your webhook.... the credentials were rejected.The token is wrong or revoked. Paste a current Content Management token and save.... the space, environment or entry was not found, check the settings.Check Space ID and Environment.... the entry changed underneath us (version conflict), retry.Someone saved the entry in Contentful while transglot was writing it. Run Publish to CMS again.- A field never appears as a key: check the field ID, check it has a value in the source locale, and check it is a plain text field.
Related
Connect a content platform
Pull content out of the CMS, store, help center or marketing tool it already lives in, translate it in transglot, and send reviewed translations back where the platform allows it.
Connect Sanity
Import Sanity documents into transglot and write reviewed translations back into each field's target-language key.