Problem/Motivation

Child of #3615902: Plan: Translation support. The builder decides which translation it edits from the URL language: Instance::ensureCurrentTranslation() and DisplayBuildablePluginBase::getTranslationLangcode() read LanguageInterface::TYPE_URL, not core's configurable negotiation. pdureau challenged it in #3555110: Symmetric translation #63.

Three other checks read the interface language: the 404 guard of IntegrationControllerBase, EntityViewOverride::checkAccess() and LanguageSwitcher. They agree while the interface language follows the URL prefix, and differ when a site negotiates it another way: session, user preference, browser.

Proposed resolution

Decide one rule, and apply it to the five places:

  • The URL language, as today: the builder edits the translation of the URL, whatever the admin interface is in. The three checks follow.
  • Or core's negotiation, with a documented setting for sites whose interface language is not the edited one.

Kernel tests for a site negotiating the interface language by session.

Remaining tasks

  • Decide the rule.

User interface changes

Depends on the rule.

API changes

None expected. #3624396: Plan: Harden InstanceInterface, IslandInterface and DisplayBuildableInterface as public API before RC1 child 3a only fixes the contract of ensureCurrentTranslation().

Data model changes

None.

Command icon 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

mogtofu33 created an issue. See original summary.

mogtofu33’s picture

pdureau’s picture

Assigned: Unassigned » pdureau

Let's try to stay close to Core, instead of having our own hardcoded mechanism. Especially if it simplifies our implementation.

We may need to be aware of LanguageInterface::TYPE_CONTENT which is is resolved, directly or indirectly (sometimes using LanguageInterface::TYPE_INTERFACE as proxy) instead of LanguageInterface::TYPE_URL.

It must be done with minimal changes of phpunit tests, and without any change of playwright tests, because the current mechanism is just a specific case (URL detection) of the Core Language Detection API.

However, let's be careful. According to Christian, if my understanding is right, this hardcoded mechanism is related to the automatic creation of config translations, something we would want to keep.

It can also be the opportunity to challenge InstanceTranslationSubscriber.

I will give a try now but this change is not mandatory for 1.0.0, so I may remove the 1.0.0-beta tag after my try.

pdureau’s picture

Assigned: pdureau » Unassigned
Status: Active » Needs work
Issue tags: -display_builder-1.0.0-beta

A proposal from Claude Code: https://git.drupalcode.org/project/display_builder/-/merge_request/508

The diff is + 340 − 83 but it is only + 60 − 42 in src/ folders, and it adds only 8 lines of PHP code.

Feedback from LLM:

Behavior change for sites: on core's default settings, the content language follows the interface language. A site whose editors keep the admin interface in English, through the "Account administration pages" setting, would now edit English. To edit other translations they need to enable "Customize Content language detection" with URL (or Session) first. I documented this in a new "Which translation is edited" section of docs/translations.md. The language_content_entity query parameter method isn't supported, because builder requests don't carry it. That's not a regression: the old code ignored it too.

We have 2 plawright fails:

 tests/src/Playwright/Tests/page_layout.multilingual.spec.ts:52:5 › Page layout multilingual publish writes a language config override @base › DE: switch with the language switcher 
    Error: expect(locator).toHaveAttribute() failed
    Locator:  locator('[data-island-action="publish"]')
    Expected: have attribute
    Received: attribute not present

tests/src/Playwright/Tests/nesting.spec.ts:9:5 › A button nested in a button leaves the builder working @base › The contextual menu still acts on a node 
    Error: expect(locator).toHaveCount(expected) failed
    Locator:  locator('.db-island-builder .db-builder-frame:not(.db-builder-frame--buffer)').contentFrame().locator('.db-island-builder [data-test="test_button"]')
    Expected: 1
    Received: 0

So I move this task out of 1.0.0 scope, until someone want to take it.

Once Playwright is OK, we will need to do manual tests to be 100% sure, the same steps as "Page Layout" there: https://www.drupal.org/project/display_builder/issues/3555110#comment-16...

mogtofu33’s picture

Issue tags: -AI-accelerated +RC blocker
mogtofu33’s picture

mogtofu33’s picture

Assigned: Unassigned » mogtofu33
mogtofu33’s picture

Issue tags: -RC blocker

As said in #3627287-5: Decide which language the builder edits: the URL one, or core's negotiated one, moving to the content language changes which translation editors land on, so it waits until after 1.0. Removing the RC blocker tag.

Until then the URL language stays the rule. Three checks still read the interface language: the 404 guard in IntegrationControllerBase::renderBuilder(), EntityViewOverride::access() and LanguageSwitcher.

I will open a bug to align them, it can land during RC.

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Needs work » Postponed