Repository navigation
feat(i18n): images and videos can be replaced per language - #62
Merged
Merged
Conversation
The kit tags the file fields (`src` on image, gallery, card and video, and the video's `poster`) with `cb_translatable`. Storage, render, the asset sweep and export already carried a translated path; what changes is the text semantics around it, decided on the field's widget (`image` / `video`, read from the upload type's parent chain): - a file with no localized version is shared, not missing, and is left out of TranslationProgress (FieldStatus gains no case: it is frozen API); - machine translation never sends a file path to a provider; - the writer accepts a scheme-less path or an http(s) URL only (`invalid_media`), and a blank value clears; - the workbench shows both files, with an upload button and a drop zone that post to the core's upload endpoint, then save at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Why
We were asked how to change an image or a video depending on the language. Until now the answer was that you could not: a file was shared by every language. Only its alt text, caption and link were translated, and for a video, its captions file. A picture with words in it stayed in the source language.
What changes
Kit. The file fields are now tagged
cb_translatable:srconimage,gallery,cardandvideo;posteronvideo.Without
klehm/content-blocks-i18ninstalled, nothing changes.i18n. A translated path already went through storage, rendering (
cb_image(), so srcset and WebP still work), the asset sweep (TranslationAssetReferenceProvider) and export/import (AssetTokenizer/AssetRewriter). What did not fit was the behaviour built for text. File fields are recognised by their widget,imageorvideo, found by walking up the upload type's parent chain. For those fields:invalid_media""FieldStatusgains no case. It is frozen API and host code maymatchon it. Shared is only how a media row displaysmissing, in the template and inworkbench.js.content_blocks_upload. The size and MIME limits and thecanEdit()check on the area apply. The workbench already held thecontent_blocksCSRF token. The path is saved immediately, with no debounce, and the preview refreshes that one block.No migration, and stored block data is unchanged.
scripts/bc-check/run.shreports no backwards-incompatible change.Docs
docs/guide/translation.md: the "What this package does not do" bullet is updated, and a new section Localized images and videos explains how to tag a file field in a custom block.docs/internals/i18n.md#localized-media: why each rule is what it is.imageandvideoreference pages (blocks-meta.mjs, regenerated), CHANGELOGs for i18n and kit, andCLAUDE.md.Tests
image/videodetection through the parent chain; the writer stores a valid path, refusesjavascript:, a tab-splitjava\tscript:,data:and a newline, and clears on blank; shared media is out of progress and outdated media still counts; machine translation sends neither the image nor the video. 191 tests pass.image,video, the gallery item and the card item. 339 pass./en/page/{id}serves the EN file and/page/{id}the source file. Main suite 199 passed, Encore 7 passed.Not in this PR
🤖 Generated with Claude Code