Introducing a new way to review your PRs.

Read the announcement

generaltranslation / gt

Full-stack localization for every framework

View on GitHub

22 documents · Updated Nov 23, 2026

docs / sanity-cms-integration

Sanity CMS integration

The Sanity CMS integration connects Sanity Studio content to General Translation. It lets editors select source documents and target locales, send content for translation, track results, and bring translated content back as reviewable Sanity content. It supports separate documents for each locale and localized fields stored in one document.

Integration boundary

The gt-sanity plugin is the Studio-facing boundary between Sanity and General Translation. Sanity remains the place where editors define content and review drafts. General Translation receives a portable form of source content and returns translated files.

The boundary has three main responsibilities:

  • Select source documents and target locales.
  • Adapt Sanity documents to the translation service.
  • Apply translated content without losing fields that are not part of translation.

The plugin does not replace Sanity's localization plugins. It configures document internationalization for document-level content and can configure sanity-plugin-internationalized-array for field-level content. The latter owns the field input UI and schema types. gt-sanity reads and writes its stored locale-item shape.

References: packages/…/index.ts• L33-95 packages/…/types.ts• L42-80 packages/…/README.md• L45-101

Package and runtime boundary

The current gt-sanity 4.0.37 package is an ESM package for Sanity 6.9.2 or later. It requires Node.js 22.12 or later and uses the host Studio's Sanity runtime packages as peer dependencies. This keeps the plugin and Studio on one set of runtime packages.

The package exposes the Studio plugin and public helpers through its package entry point. Studios on Sanity 6.0 through 6.8 should remain on the 3.1.x generation. A CommonJS require path is not part of the 4.x package boundary.

References: packages/…/package.json• L1-3 packages/…/package.json• L25-45 packages/…/package.json• L99-117

Plugin configuration

Plugin configuration defines the translation scope and the rules that shape the translation boundary. The plugin resolves one source locale and removes duplicate or repeated source entries from the target locale list before it configures Studio or contacts General Translation.

ConcernPurpose
Source and target localesDefines the source language and the languages that can receive translations.
translateDocumentsSelects document types or document IDs that the translation UI can manage.
translationLevelChooses separate locale documents, in-place localized arrays, or a mix of both.
fieldLevelDocumentsIn mixed mode, selects the types that use localized arrays.
languageFieldNames the language field on document-level translations. It defaults to language.
singletons and singletonMappingGives stable IDs to translated singleton documents.
ignoreFields, skipFields, and dedupeFieldsControls which values stay unchanged, are omitted, or receive a locale-specific value in a translated document.
additionalSerializers and deserializersExtends the content format for custom Sanity types or Portable Text content.
allowNonDefaultSourceLocalesAllows a document outside the configured source locale to act as the original for its translation group.
previewUrlGives General Translation a page URL for source and imported content.
Automatic actions and edit preservationSets the starting behavior for refresh, import, reference patching, publication, and local edit capture.

The plugin reads General Translation project credentials from a Sanity document in the configured secrets namespace. Explicit plugin values provide the base configuration. Values from the secrets document can provide the project and API key used by Studio actions.

References: packages/…/index.ts• L98-183 packages/…/index.ts• L231-285 packages/…/core.ts• L33-72 packages/…/useSecrets.ts• L11-34 packages/…/README.md• L202-248

Translation representations

Sanity content can use one of two product models. The model determines where a target translation lives and how an editor browses it.

ModelStorage viewTranslation resultLocale browsing
Document levelOne source document plus one linked document per target localeA target document with its language field setA locale-specific document pane can group the linked documents
Internationalized arrayOne document with locale items inside localized fieldsA target-locale item is added or updated in the source documentThe source document contains all locale values
MixedConfigured document types use either modelEach type follows its selected modelOnly document-level types are grouped as separate locale panes

The default is document level. Enabling field-level schema types does not change the translation model by itself. A project must also select internationalizedArray or mixed translation behavior when it wants translation results written into localized fields.

References: packages/…/strategy.ts• L12-16 packages/…/strategy.ts• L58-93 packages/…/index.ts• L294-357

Document internationalization

Document-level localization uses Sanity's document internationalization model. A translation.metadata document records the original document and the target documents that belong to the same translation group. Each target document carries the configured language field.

By default, the configured source locale is the original. With allowNonDefaultSourceLocales, a document outside that locale can become the original when it is first translated. The group then records that language in gtSourceLanguage. All other members are translations and cannot become a second original.

When a translation is imported, the plugin uses the source revision tied to the translation when that revision is available. It merges translated fields with the source snapshot and creates or updates the target as a draft. Existing translated drafts are preferred over published copies. A published target is copied into a draft before an import patch, so live content changes only after an editor publishes it. Existing values in configured deduplicated fields remain during a re-import.

The plugin rechecks group metadata before it creates a target. It can replace a weak reference to a deleted target. A missing original, a target entry that points back to the original, or a document that is no longer the group's original produces a readable diagnostic instead of an unsafe write.

The source document can have no language field when it predates the plugin. The integration treats that document as the configured source locale. A configured singleton mapping gives each locale a predictable document identity. The configured language field is system data during a patch, so an import does not overwrite the target locale.

This diagram shows how one original is related to target documents and review drafts.

flowchart LR
  S[Original document] --> M[translation.metadata group]
  M --> T1[Target document: locale A]
  M --> T2[Target document: locale B]
  T1 --> D1[Draft for review]
  T2 --> D2[Draft for review]

References: packages/…/documentLevelPatch.ts• L31-178 packages/…/createI18nDocAndPatchMetadata.ts• L12-104 packages/…/getOrCreateTranslationMetadata.ts• L31-78 packages/…/documentLevelPatch.test.ts• L11-169 packages/…/documentLevelPatch.test.ts• L277-523

Field-level localization

Field-level localization stores each locale value in the same Sanity field. The stored item has a locale identity and a value. A localized title therefore contains one item for the source language and another item for each target language.

The plugin can create the reference plugin's schema types and Studio controls from the same locale configuration used by translation. The default field types are strings and text. Projects can add Portable Text or custom field definitions. Language labels can come from configured titles or a custom mapping. A project that registers the reference plugin itself should leave this part of gtPlugin disabled so the types are registered only once.

Field exclusions apply through schema options. options.gt.exclude marks a field or type as outside the translation boundary. The serializer also honors standard localization exclusion options and the legacy localize: false field setting. These rules can apply inside nested objects and arrays.

References: packages/…/fieldLevelConfig.ts• L8-72 packages/…/schemaOptions.ts• L7-31 packages/…/plugin.test.ts• L75-161 packages/…/index.ts• L126-170 packages/…/README.md• L45-127

Studio structure

The integration exposes optional structure helpers for teams that want to browse document-level translations by locale. gtStructureItems adds a list item for each configured type, then expands it into an original pane and one pane per target locale. gtStructure provides the complete structure when no other Studio list items need to be preserved.

The structure is opt-in because structureTool owns the Studio layout. Types localized through internationalized arrays are excluded from locale panes because their target values remain inside the source document. Generated document lists use the same pinned Sanity API version as the plugin client, which gives custom list filters a stable query contract.

This diagram shows the locale panes that can sit below a document type.

flowchart TD
  C[Content] --> P[Post]
  P --> S[Original locale]
  P --> E[Spanish]
  P --> F[French]

References: packages/…/localizedStructure.ts• L13-23 packages/…/localizedStructure.ts• L62-87 packages/…/localizedStructure.ts• L90-159 packages/…/README.md• L288-324

Serialization contract

Serialization turns a Sanity document into structured HTML that General Translation can process while keeping enough structure to rebuild the document. The format carries document identity and revision metadata. Field names, object boundaries, array boundaries, and Portable Text block keys remain available during import.

The serializer sends translatable strings and rich text. It stops at references, media, dates, numbers, and other non-language values unless configuration adds a different rule. It preserves line breaks, Portable Text styles, marks, annotations, and inline objects through the round trip. It removes ignored and deduplicated fields before upload. Custom serializers and deserializers extend the contract for content types that the default format cannot represent.

For internationalized arrays, the source-locale item is first reduced to its value. This prevents other locale values from being sent as source text. On import, the target value is merged into the matching locale item while other locale items and their keys remain in place.

This diagram shows the document path from Sanity to translation and back.

flowchart LR
  D[Sanity document] --> F[Filter translatable content]
  F --> H[Structured HTML file]
  H --> G[General Translation]
  G --> R[Translated HTML file]
  R --> U[Deserialize and merge]
  U --> S[Sanity draft or localized field]

References: packages/…/index.ts• L47-73 packages/…/index.ts• L110-170 packages/…/BaseDocumentDeserializer.ts• L23-97 packages/…/collapse.ts• L7-19 packages/…/BaseDocumentSerializer.test.ts• L210-279 packages/…/BaseDocumentDeserializer.test.ts• L122-195 packages/…/roundTrip.test.ts• L267-521

Document merge

Document merge combines translated values with the source snapshot before Sanity writes the result. It updates translated strings and matching array or object members. Fields that are absent from the translated result remain from the source document.

Array objects are matched by _key, not by their current position. This keeps source-only blocks and non-translated fields in place. Field-level merge writes the translated value under the target locale instead of replacing the full source document.

References: packages/…/BaseDocumentMerger.ts• L11-187 packages/…/BaseDocumentMerger.test.ts• L126-265

Translation adapter

The adapter gives the Studio workflow a stable service boundary. It lists target locales, creates a translation task, reports task status, and downloads a completed translation. The adapter uses a document ID and an optional source revision so a result stays tied to the content version that was uploaded.

The Sanity API boundary delegates file and job operations to General Translation. A source file declares its document language when non-default source locales are enabled, while the request still keeps the configured source locale as the project default. The adapter maps this service contract back to the locale and status shapes used by Studio.

Bulk uploads use a readable Sanity document label when one is available. File identity remains the document ID and uploaded revision, so a label change does not start a new translation identity. The single-document adapter path uses the document ID as its stable file name. At the service boundary, locale aliases are converted to configured canonical locale values in both requests and responses.

References: packages/…/types.ts• L42-82 packages/…/api.ts• L11-36 packages/…/core.ts• L44-51 packages/…/createTask.ts• L9-47 packages/…/getLocales.ts• L6-24 packages/…/api.test.ts• L49-168 packages/…/api.test.ts• L170-337 packages/…/uploadFiles.ts• L10-44

Preview URLs

Preview URL support connects a translation file to the page that displays its content. A project supplies the site origin and location rules by document type. The plugin resolves the first location for each source document in its published language and sends that URL with the source upload.

After import, the plugin resolves the written translation from its draft view and sends the target-language URL back to General Translation. It follows selected fields through local and cross-dataset references when a resolver needs them. A missing page or a failed URL update leaves translation work intact and produces a warning instead of stopping the upload or import.

References: packages/…/previewUrls.ts• L27-42 packages/…/previewUrls.ts• L126-187 packages/…/previewUrls.ts• L266-301 packages/…/updatePreviewUrls.ts• L15-45 packages/…/previewUrls.test.ts• L97-123

Locale selection

Locale selection controls which target locales a bulk action touches. The source locale is never a target. A locale is selected unless its enabled flag is explicitly false, so existing locale data remains active when no selection state has been stored.

For an original outside the configured source locale, the original's language is excluded and the configured source locale is offered as a target. This lets the document translate into the default language without asking it to translate into itself.

The Translations page provides a searchable dropdown. A document translation view provides a selector with a toggle-all action. Confirmation dialogs show the selected locale set before an editor starts a bulk action. Translate, import, save-local-edits, reference patch, and publication actions use that set.

Selection is part of workflow state rather than a separate request option. If an editor removes a locale while its translation is still running, status refresh continues to poll that locale until it reports ready. This clears the pending state without bringing the locale back into later user-selected actions.

References: packages/…/LocaleDropdown.tsx• L29-91 packages/…/LocaleSelector.tsx• L11-55 packages/…/SelectedLocalesNote.tsx• L7-17 packages/…/TranslationsProvider.tsx• L476-507 packages/…/locales.ts• L15-45 packages/…/getLocales.ts• L10-24

Translation lifecycle

The Studio translation lifecycle coordinates Sanity reads, General Translation work, and Sanity writes. It keeps the uploaded source revision with the task so a later document revision does not make a completed result appear to belong to a different run. The source revision also survives a Studio refresh.

When an editor starts a run, the integration follows this sequence:

  1. Load original documents and available target locales.
  2. Recheck document roles when non-default source locales are enabled.
  3. Optionally capture existing Sanity translations against the source version held by General Translation.
  4. Serialize and upload source files.
  5. Initialize project context and enqueue work for selected target locales.
  6. Refresh status until a translated file is ready.
  7. Download and deserialize the file.
  8. Apply the document-level or internationalized-array strategy.
  9. Resolve the imported page URL when configured.
  10. Optionally repoint references and publish translated documents.

The editor can import one ready locale, import all ready results, or import only results that do not already exist in Sanity. It can also upload existing translations without enqueueing new work. Automatic refresh and automatic import are enabled by default. Reference patching and publication are off by default because they can change content used by readers or other documents.

Retranslation from scratch is a separate forced run. It asks General Translation to discard the stored result for the selected source version and skips edit capture. The plugin records the new job IDs and hides the older completed result until a newer result arrives. If the forced job fails, the replaced result stays unavailable only for the active retry state, and the editor can start the operation again without importing the result that the run was meant to replace.

The central Translations tool keeps a bulk run active until all enqueued locales report back. Imports for the same document are serialized when they update localized arrays because those updates read and write one Sanity document. A refresh response is accepted only while its document, locale, branch, and uploaded-version scope is current.

References: packages/…/TranslationsProvider.tsx• L778-1003 packages/…/TranslationsProvider.tsx• L1025-1126 packages/…/TranslationsProvider.tsx• L1128-1372 packages/…/TranslationsProvider.tsx• L1386-1538 packages/…/TranslationsProvider.tsx• L1551-1678 packages/…/checkTranslationStatus.ts• L9-96 packages/…/forcedJobs.ts• L6-79 packages/…/TranslationsProvider.test.ts• L461-665

Edit preservation

Translated content can be edited in Sanity after import. Save Local Edits sends those existing translations back to General Translation before a later source upload. It uses the source file version already held by General Translation, so local edits remain tied to the source that produced them.

This behavior is off by default and is remembered per Sanity project and dataset after the editor enables it. A save-local-edits action seeds matching source files first, then uploads only translation content that exists in Sanity. A retranslate-from-scratch run deliberately skips that capture. Edit preservation applies to groups whose original is in the configured source locale. The field-level model always translates from that locale.

References: packages/…/captureExistingTranslations.ts• L29-110 packages/…/collectExistingTranslations.ts• L35-112 packages/…/uploadFiles.ts• L10-44 packages/…/uploadTranslations.ts• L8-54 packages/…/TranslationsProvider.tsx• L778-829 packages/…/TranslationsProvider.tsx• L1025-1126

Hooks and Sanity services

The integration uses hooks to provide the Sanity client, service credentials, and document role to Studio components. The client uses one pinned Sanity API version for plugin queries and structure lists. The secrets hook reads one Sanity document from the configured namespace and exposes only its non-system fields to the translation workflow.

The provider is the shared state layer for both the central Translations tool and the per-document translation view. It owns document loading, locale selection, task status, import progress, remembered preferences, uploaded source-version pins, preview URL updates, forced-job tracking, and the actions that call the adapter and Sanity APIs. Status polling skips downloaded or settled results and checks forced job status when a forced run still needs a newer result.

When non-default source locales are enabled, useDocumentRole follows changes to a document's translation group. The editor can distinguish an original from a translation or an unresolved group before it offers translation controls. A failed role check hides unsafe controls. A late lookup does not replace the role for a newer document or group state.

References: packages/…/useClient.ts• L3-8 packages/…/useSecrets.ts• L11-34 packages/…/useDocumentRole.ts• L23-109 packages/…/useDocumentRole.test.ts• L87-189 packages/…/useDocumentRole.test.ts• L191-271 packages/…/documentRoleState.ts• L18-31 packages/…/TranslationsProvider.tsx• L301-475 packages/…/TranslationsProvider.tsx• L1386-1538

Editor components

The plugin adds two Studio entry points. The Translations tool manages many original documents from one table. The Translate document action opens the same status and import experience for one document. Both views use the same provider, so their status and import behavior follow the same rules.

The editor surface supports these operations:

  • Select target locales and start translation.
  • Refresh task status and import ready files.
  • Save local edits as the current translation baseline.
  • Retranslate selected locales from scratch and replace the stored result.
  • Patch references to translated documents.
  • Publish translated drafts when the editor chooses to do so.
  • Inspect effective configuration and translation counts through Debug Info.

The confirmation dialogs state which selected locales an action will affect. Import All overwrites existing translations, while Import Missing checks translation metadata and writes only locales that are not already present. Save Local Edits replaces the stored service translation without starting new translation work.

Translation controls are shown for originals only. A translated document is content for review or publication, not a new source task. In the document view, automatic reference patching and publication run only after a successful import while the document remains an original. Local edit preservation is unavailable for a non-default original because its translation baseline is not the configured source-locale flow.

References: packages/…/index.ts• L353-375 packages/…/translateAction.tsx• L8-31 packages/…/TranslationsTool.tsx• L54-249 packages/…/TranslationsTool.tsx• L251-436 packages/…/TranslateAllDialog.tsx• L20-103 packages/…/ImportAllDialog.tsx• L11-51 packages/…/ImportMissingDialog.tsx• L11-51 packages/…/UploadExistingDialog.tsx• L11-52 packages/…/RetranslateDocumentDialog.tsx• L12-67 packages/…/TranslationView.tsx• L42-381 packages/…/TranslationView.tsx• L392-631 packages/…/TranslationView.test.ts• L223-464

Reference and publication actions

Document-level translations can contain references to source documents. The reference action finds the target document for the same locale from translation metadata and writes the translated reference to a draft. This keeps linked content in the same language without changing published content automatically.

Publication is a separate action. It publishes translated drafts only when the source document is published. Automatic publication is disabled by default. An imported translation therefore normally remains a draft until an editor or an enabled workflow publishes it.

Reference lookup supports groups whose original is outside the configured source locale. It can resolve a reference from any member of that group to the target locale. Publication can limit its work to the selected locales.

References: packages/…/findDocuments.ts• L20-59 packages/…/resolveRefs.ts• L27-94 packages/…/resolveRefs.ts• L127-239 packages/…/publishDocuments.ts• L6-89 packages/…/TranslationsProvider.tsx• L1690-1908

The Translation operations page gives the system-wide view of translation work. Use the Translation API client page for the shared service boundary. The Payload CMS integration page describes a separate CMS adapter. The GTX command-line workflows page covers command-line translation flows. The Locadex operations page covers repository localization operations. The session recording localization and bundle analysis pages describe related product workflows. This page describes the Sanity-specific document, field, Studio, and import behavior.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep translationLevel, fieldLevelDocuments, document-internationalization schema types, and locale structure grouping aligned. A type localized in place must not also be treated as a per-locale document.
  • Keep the serialized HTML metadata and the deserializer in sync. The document ID, type, revision, and serialization version support safe imports and strategy selection.
  • Keep translation.metadata query fragments aligned with document creation, import, role checks, and publication. The gtSourceLanguage marker must identify the same original everywhere.
  • Preserve the source file ID and uploaded revision across upload, status, download, edit capture, and import. Status keys and General Translation files depend on that identity.
  • Keep source preview URL resolution and imported preview URL updates aligned with the document that was actually uploaded or written. A URL failure must not turn a successful translation into a failed import.
  • Keep field exclusion rules consistent between source serialization and target document merge. Ignored, skipped, and deduplicated fields have different contracts.
  • When changing automatic actions, review draft creation, reference patching, and publication together. These actions do not have the same effect on reader-visible content.
  • If field-level plugin registration changes, check that generated internationalizedArray* schema types are registered exactly once and use the same locale IDs as gtPlugin.
  • Keep the gt-sanity release line aligned with the host Sanity generation, Node.js runtime, ESM module model, and peer runtime packages.
  • Keep locale selection state aligned across selectors, confirmation text, bulk handlers, status rows, and publication queries. A selected locale must be the locale that the action sends or writes.
  • Keep selected locales separate from pending locales. A deselected locale that is still running must remain in status polling until its pending marker clears.
  • Keep refresh scope invalidation and in-flight counting aligned. A stale response must not replace current statuses, while a slow response for an unchanged scope must still be accepted.
  • Keep source-locale handling aligned across role checks, metadata markers, per-file upload locales, target selection, reference lookup, and import.
  • Keep readable file names separate from file identity. Uploads must continue to use the same document ID and source revision when a title, name, or slug changes.
  • Keep source seeding in the existing-translation upload path. Uploading translations without first creating the matching source file cannot establish the source file and revision used by General Translation.
  • Keep string escaping, whitespace markers, and Portable Text recovery rules aligned. The serializer and deserializer must agree on which values are literal text and which values carry preserved structure.
  • Keep document-level patch rules aligned with the language-field setting, deduplicated fields, and draft creation path. Re-imports must not replace locale identity or editor-owned deduplicated values.
  • Keep import concurrency aligned with the storage model. Imports that patch one localized-array document must not run at the same time.
  • Keep forced-run job IDs, superseded completion times, and pending status keys aligned. A forced run must not auto-import the result it is replacing, and a failed job must clear its pending state without restoring that result.
  • Keep the document view's completed-result baseline aligned with provider status resets. A retranslation must import only a result that completes after the forced run starts.

Important failure modes

TriggerConsequenceGuard
The source locale also appears in locales, or a target locale is repeated.Studio localization plugins can receive duplicate language entries and enter an update loop.Resolve target locales before plugin setup and keep locale IDs unique.
A locale is deselected while its translation is still running.The pending marker can remain forever and the run can appear stuck.Continue polling selected locales plus pending locales.
A slow refresh or role lookup returns after the editor changes its scope.Old state can replace state for the current document, group, or revision.Reject responses from an old refresh or role scope.
A document outside the source locale is treated as a source without a stable group marker.A translation group can have conflicting originals or a translation can be translated again.Use gtSourceLanguage and allow only the group's original to start work.
A translation group has no original or its original was deleted.Translation controls cannot safely identify the source.Show the unresolved-role diagnostic and restore the original before translating.
The secrets document is missing or has no usable credentials.Service calls cannot start.Load credentials from the configured namespace and check the Studio warning.
A translated file is imported with the wrong strategy for its document type.Content can be written to a separate document when it belongs in a localized field, or the reverse.Keep translationLevel and fieldLevelDocuments aligned with the schema.
A source document changes after upload and status is checked against its live revision.A ready result can look like it was never translated.Use the revision pinned at upload time for status and file queries.
Existing translations are captured after the new source revision is uploaded.Local edits can be attached to a version that no longer matches the source run.Capture them before upload and use the source file version already held by General Translation.
Existing translations are uploaded without a matching source file.General Translation cannot attach the stored translation to the source file and revision.Seed source files before collecting and uploading existing translations.
Import All runs while a translated document is edited locally.The imported result can overwrite the local translation.Use Save Local Edits or import only missing translations.
Two locale imports for an internationalized-array document run at the same time.One in-place patch can replace another locale's update.Import locale results sequentially through the Studio workflow.
A readable document label is used as file identity.A title, name, or slug change can create a new translation source.Keep file identity tied to the document ID and source revision.
A preview resolver or General Translation metadata update fails.A source or translated page has no review link, but the translation itself can still succeed.Record the failure and continue the upload or import.
Reference patching is not run after document-level import.Translated documents can still point to source-language documents.Run Patch References or enable it after reviewing its draft changes.
Automatic publication is disabled and the editor checks only the published view.The translation exists but is not visible to readers.Review the translated draft and publish it when ready.
A 4.x plugin is installed in a Sanity 6.0–6.8 or older Studio, or the host misses the Node.js and ESM requirements.The plugin can fail to load or create incompatible runtime boundaries.Use 3.1.x for Sanity 6.0–6.8 and use 4.x only with Sanity 6.9.2+, Node.js 22.12+, and ESM.
A re-import treats the configured language field as translated content.The target document can lose its locale identity.Treat the configured language field as system data.
A re-import replaces a translated deduplicated field with the source value.An editor's locale-specific value can be lost.Restore matching deduplicated values from the existing target document.
An import writes translated values directly to a published target.Readers can see an unreviewed translation.Seed or update the drafts. target and publish through the separate publication action.
A forced run is treated as ready because General Translation still reports the older completed result.Auto-import can restore the translation that the editor asked to replace.Track the forced job and accept only a completion newer than the superseded result.
A forced job fails or cannot be checked while the old result is hidden.The UI can remain pending forever or report a result that was never replaced.Keep the job pending when status is unknown, then settle failed or unknown jobs and clear their pending keys.
Retranslation starts before the branch or source scope is ready.The run cannot distinguish the discarded result from the new result.Require the branch before forcing a run and keep the current document, locale, and version scope.
A non-default original loses its original role during import.The plugin can write or publish content to a document that is now a translation.Recheck the role before import and again before reference patching or publication.

Key files

FileWhy to read it
packages/…/package.jsonPackage and host-Studio boundary, including runtime, module, peer, and Sanity generation requirements.
packages/…/README.mdUser-facing setup, field-level localization, edit preservation, non-default source locales, preview URLs, and Studio actions.
packages/…/CHANGELOG.mdRelease-level behavior changes, including forced retranslation and protection from importing superseded results.
packages/…/index.tsPlugin entry point. It resolves configuration and registers the translation tool, document action, and localization plugins.
packages/…/core.tsShared configuration and default workflow preferences used by the adapter and Studio provider.
packages/…/api.tsSanity's service adapter and locale mapping boundary.
packages/…/types.tsAdapter boundary and document, task, locale, status, and preview metadata shapes.
packages/…/strategy.tsMapping between document-level and internationalized-array translation behavior.
packages/…/documentLevelPatch.tsDocument-level import behavior, source revision resolution, and translation group lookup.
packages/…/createI18nDocAndPatchMetadata.tsTarget document creation and translation-group membership.
packages/…/getOrCreateTranslationMetadata.tsTranslation-group discovery, original checks, and source-language marking.
packages/…/internationalizedArrayPatch.tsIn-place localized-field import and draft-safe updates.
packages/…/index.tsSource document to structured HTML contract and field filtering.
packages/…/BaseDocumentDeserializer.tsStructured HTML back to Sanity data.
packages/…/BaseDocumentMerger.tsPreservation of non-translated fields and keyed array items during import.
packages/…/roundTrip.test.tsEnd-to-end serialization, translation-shaped edits, deserialization, and merge guarantees.
packages/…/fieldLevelConfig.tsConfiguration bridge to the reference internationalized-array plugin.
packages/…/localizedStructure.tsOptional locale-based Studio browsing structure.
packages/…/previewUrls.tsPage URL resolution for source and translated documents.
packages/…/uploadFiles.tsSource-file upload contract, including file naming, document identity, locale, revision, and preview metadata.
packages/…/collectExistingTranslations.tsCollection of document-level and field-level content already edited in Sanity.
packages/…/bulkSources.tsBulk source selection, original-role checks, and exclusion of translation-group members.
packages/…/checkTranslationStatus.tsReady-result lookup and completion-time comparison for uploaded translation versions.
packages/…/forcedJobs.tsTracking and settlement of forced retranslation jobs.
packages/…/batchProcessor.tsImport batching and per-document serialization for in-place localized-array writes.
packages/…/importUtils.tsReady-file selection, download, import progress, and post-import preview updates.
packages/…/translationSource.tsTranslation-group roles, original-language rules, and metadata queries.
packages/…/documentRoleState.tsSafe editor state when a document's group role is resolving, valid, or unverified.
packages/…/locales.tsLocale normalization, selection defaults, and polling scope rules.
packages/…/TranslationsProvider.tsxShared translation state and end-to-end Studio actions.
packages/…/TranslationsTool.tsxCentral multi-document translation interface and selected-locale bulk actions.
packages/…/RetranslateDocumentDialog.tsxConfirmation boundary for replacing selected document translations from scratch.
packages/…/TranslationView.tsxPer-document translation status, role gating, automatic import, and action interface.
packages/…/useDocumentRole.tsLive document-role updates used by the Translate view.
packages/…/resolveRefs.tsDraft-safe replacement of source references with translated references.
packages/…/publishDocuments.tsPublication of translated drafts after source publication.