Repository navigation
fix: write downloaded blocks/json fields and component lists correctly (nested, incremental, structure changes) - #131
Merged
Conversation
…components A json/blocks field is uploaded as one key per leaf. On download the leaves were grouped by their owning entry/component only, and the key was split at the wrong segment inside dynamic zone components, so: - two json/blocks fields of one component overwrote each other and the second one stayed in the source language, - blocks inside components nested in a dynamic zone were dropped, and the final write replaced the whole component list, losing its plain fields. `locateDownloadedField` now finds the exact field segment of a key (also behind dynamic zone `id;component` segments and component ids, and for json values whose path ends in array indexes or numeric keys), and leaves are accumulated per full field path. Incremental sync now takes an entry with any changed key with all of its keys, so a changed entry is rewritten exactly as a full sync would, instead of rebuilding fields from the changed leaves only (which put source text back into every unchanged leaf). The per-key download loop moves to `collectDownloadedContent` and key parsing to `parseLocalazyKey`, both pure and tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ource structure - Repeatable component and dynamic zone items are positioned by the source entry; the arrays were then compacted, so any item without downloaded values (an empty caption, or every unchanged item in an incremental sync) shifted all later items onto their neighbours. The compaction is removed; both callers merge onto a complete entry. - On update, a blocks or json field is replaced with the value rebuilt from the current source value instead of being deep-merged into the localized one, which kept marks, paragraphs and keys removed from the source. - json fields are rebuilt like blocks: a copy of the source value with each string leaf replaced by its translation, found by the same key segments `flattenObject` produces (ids included). Object/array shapes, numeric keys and non-string values come from the source, and leaves no longer in the source are ignored. - When the source changed a list's layout (items added or removed, dynamic zone components replaced or reordered), the localized list is rebuilt from the source items instead of merging translations into unrelated items or mixing two components into one. The create payload merge moves to `buildLocalizedCreateEntry`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ore updating Dynamic zone and repeatable component items were populated in an un-awaited `forEach(async …)`, so their relation lookups mutated the update payload while Strapi was already resolving it, failing updates with `Document with id "…", locale "null" not found` (a different document on each run). Items are now awaited in sequence. json and blocks values are complete values: populate no longer walks into them as if they were part of the schema (which added stray properties such as `links.links`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… placements Runs the plugin's own upload and download transforms for a schema with json/blocks fields at the top level (side by side), in single, repeatable and nested components, in dynamic zones and in repeatable components inside dynamic zone items, and checks create, update, incremental, multi-language, stale-key and source-structure-change cases against an independent walk over the schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
honzabubenik
approved these changes
Nov 11, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes how downloaded translations are written back to Strapi for blocks (rich text) and json fields and for lists of components. It applies to every download path: UI Full Sync, UI "Download changes", and the webhook.
Found while localizing a real Strapi 5 site: Czech source, English via Localazy AI, and an About page built as a dynamic zone of components with blocks fields everywhere. Then generalized and checked against every place Strapi allows these fields.
What 1.7.0 did wrong
hero.title+hero.line): the second field's leaves were written into the first, and the second stayed in the source language.timeline.stops[].notes,stops[].quote.text): dropped. The final write replaced the wholestopslist, so its plain fields (label, captions) were lost too.storyof 11 of 12 sessions, the simplest case (one top-level blocks field).Document with id "…", locale "null" not found. The lookups ran in an un-awaitedforEach(async …)while Strapi was already resolving the payload.{"2024": …}) became arrays thousands of items long. Array items with anidlanded at indexid. Top-level arrays were handled as plain fields, and populate added stray properties (links.links).Changes
locateDownloadedFieldfinds the exact field segment of a downloaded key: behind dynamic zoneid;componentsegments and component ids, and for json paths ending in indexes or numeric keys. Leaves are accumulated per full field path.collectDownloadedContent(the extracted, pure download loop) takes an entry with any changed key with all of its keys, so incremental sync rewrites a changed entry exactly as Full Sync would.resetArrayKeysDeepremoved). Both callers merge onto a complete entry.overlayJsonTranslation): a copy of the source value with string leaves replaced by translations, looked up with the same key segmentsflattenObjectproduces. On update, blocks and json fields replace the localized value instead of merging into it.alignLocalizedEntryToSource: when a list that receives downloaded values has a different layout in the source (length, or dynamic zone component sequence), the localized list is rebuilt from the source items (without their component ids) before merging. Lists with the same layout merge as before.populateCreateUpdateEntryWithBaseEntryawaits dynamic zone and repeatable items, and no longer walks into json/blocks values.parseLocalazyKey→utils/parse-localazy-key.ts(the service delegates to it), and the create payload merge →buildLocalizedCreateEntry.findSetupModelByCollectionUidreturnsundefinedinstead of throwing for a model without setup.Behaviour changes worth noting
Tests
transfer-round-trip.test.tsruns upload → translate → download through the plugin's own transforms:projectBlocksFields,flattenObject,pickEntries,getPickPathsWithComponents,collectDownloadedContent, and the create/update builders.overlay-json-translation.test.ts,json-fields-download.test.ts,populate-create-update-entry-with-base-entry.test.tsare focused tests. Each behaviour test was checked to fail on 1.7.0.test:ts:back,test:ts:front,lint(only the existing admin warning),format:check,buildandverifypass locally.Verified on a real Strapi 5.50 instance
On a local mirror of the site above, with the built plugin:
Not changed
🤖 Generated with Claude Code