Problem/Motivation
The Embed component dialog shows a component's name and description, and the title and description of each prop and slot, exactly as written in the component's YAML, whatever the interface language. On a site whose editors work in another language, the dialog stays in English.
Steps to reproduce
- Install Drupal with the Standard profile and enable SDC Embed, Language and Interface Translation. Add Portuguese and make it the default language.
- At Configuration > Text formats and editors > Full HTML, add the "Embed component" button and enable the "Embed Single Directory Components" filter. At
/admin/config/content/sdc-embed, check "Include components provided by modules". - At Configuration > Regional and language > User interface translation, translate "Title" and "Content" to Portuguese.
- Create a Basic page in Full HTML and click "Embed component".
Expected: the picker shows "Título — navigation", and once chosen, its slot shows "Conteúdo".
Actual: "Title — navigation" and "Content".
Proposed resolution
Translate these texts in SdcDiscovery, where the module already normalizes the component definitions, the same way core translates meta:enum labels in ComponentMetadata::parseSchemaInfo():
- a prop's title and description with the prop's
x-translation-context, the only translation context the SDC metadata schema defines; - the component's name and description, and each slot's title and description, with the empty context.
The texts stay strings, as the rest of the module expects. Empty texts are not passed through translation, so they do not add blank rows to the translation UI.
Checked in the browser with navigation:title and Portuguese as the interface language: the picker shows "Título — navigation", the "HTML tag for title" prop shows its translation in the "HTML tag" context, and the "Content" slot and its description show theirs. In English nothing changes. The strings are registered in the translation UI with their context the first time the dialog is opened.
The MR adds SdcDiscoveryTest::testTextsAreTranslated(), which checks every text and its context. It fails without the change.
Remaining tasks
Review.
User interface changes
The dialog and the settings form show the component texts in the interface language. The picker sorts by the translated names.
API changes
None.
Data model changes
None.
AI usage
AI-Generated: Yes. I used Claude Code (Anthropic) to write the change, the unit test and a first draft of this summary. I verified it in the browser in English and Portuguese, reviewed the code, and confirmed the new test fails without the change and passes with it.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | sdc_embed-translatable-component-texts-3630637-3.patch | 7.96 KB | tiago |
Issue fork sdc_embed-3630637
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
tiago commentedMR !6 is ready for review and its pipeline passes.
Attached below is the MR diff as a patch for 1.2.0.
It touches the same lines of
SdcDiscoveryas #3630631: Enum props show their raw values in the dialog instead of their meta:enum labels, so whichever is merged second will need a reroll.