Problem/Motivation

On Configuration → Regional and language → Content language and translation (`/admin/config/regional/content-language`), each bundle is listed using only its human-readable label (`$bundle_info['label']`), not its machine name. Bundle labels are not required to be unique.

When two or more bundles of the same entity type share the same label, they appear as duplicate rows in the table and administrators cannot tell which bundle they are configuring. This affects any bundleable content entity (nodes, paragraphs, media, etc.), not only Paragraphs.

Example:
- Paragraph type `text` — label: "Text"
- Paragraph type `sidebar_text` — label: "Text"

Both appear as "Text" in the Paragraph row. Changing `sidebar_text`’s label to "Sidebar text" makes it visible again, which confirms the bundles are present but indistinguishable by label alone.

Steps to reproduce

1. Ensure the Language module and Content translation are enabled.
2. Create two bundles of the same entity type with the same label, e.g.:
- Paragraph type `text` — label "Text"
- Paragraph type `sidebar_text` — label "Text"
3. Go to `/admin/config/regional/content-language`.
4. Enable custom language settings for Paragraph (if not already).
5. Open the Paragraph details section.

Expected: Each bundle is listed and clearly identifiable (e.g. label + machine name, or unique display per row).
Actual: Only one paragraph labeled 'text' is visible/listed.

Proposed resolution

When multiple bundles of the same entity type share the same label string, append the bundle machine name for display only, e.g.:
- `Text (text)`
- `Text (sidebar_text)`
Unique labels should remain unchanged. Form structure and configuration export must continue to use bundle machine names only.

User interface changes

Duplicate bundle labels on the content language settings form show the machine name in parentheses.

Issue fork drupal-3593441

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

marcin dębicki created an issue. See original summary.

marcin dębicki’s picture

Issue summary: View changes
marcin dębicki’s picture

Issue summary: View changes

skifdesu made their first commit to this issue’s fork.

skifdesu’s picture

Status: Active » Needs review

Added MR which solves the issue.

smustgrave’s picture

Status: Needs review » Needs work

Instead of a new test can we expand an existing one

skifdesu’s picture

Status: Needs work » Needs review

> Instead of a new test can we expand an existing one

Moved the test to the existing LanguageSelectorTranslatableTest.php test.

smustgrave’s picture

Status: Needs review » Needs work

This is a perfect example of a test that can be a kernel now thanks to https://www.drupal.org/node/3502609

skifdesu’s picture

Assigned: Unassigned » skifdesu
Status: Needs work » Needs review

Converted the test to a kernel test using HttpKernelUiHelperTrait as suggested in #16.

amitgoyal’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed the fix and tested locally.

The fix uses array_count_values() to detect when multiple bundles share the same label, and disambiguates them by appending the machine name in the format "Label (machine_name)". Bundles with unique labels are unaffected.

Test coverage: a new kernel test ContentLanguageSettingsFormTest using HttpKernelUiHelperTrait creates two content types both named "Text" (machine names text and sidebar_text) plus a unique "Unique" type, then asserts:
- "Text (text)" and "Text (sidebar_text)" appear in the form
- "Unique" appears as-is (no machine name appended)

Local results: 1 test, 17 assertions — all pass. Browser validation on DDEV confirmed "Text (text)" and "Text (sidebar_text)" both appear correctly on /admin/config/regional/content-language.

LGTM.

quietone’s picture

Changes to the UI should have before and after images available from the issue summary.

godotislate’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs screenshots, +Needs issue summary update

NW for #12.