Add option to limit displayed languages in the language selector block

Created on 27 March 2025, 21 days ago

Problem/Motivation

Currently, the advanced_language_selector block displays all available languages configured on the site. However, in some use cases, site administrators may want to display only a subset of languages β€” for example, showing only English and Spanish, while hiding Arabic (even if translations exist).

This flexibility is often needed for:

Multilingual sites where certain translations are still in progress.

Regional/language-specific content targeting.

Testing or phased rollout of new languages.

Proposed resolution

Add a new block configuration setting (allowed_languages) to let site administrators select which languages should be shown in the language switcher.

Suggested implementation

Add a checkboxes field to the block configuration form listing all available languages.

Store the selected languages in the block's $configuration.

Filter $links->links in build() to only include allowed languages.

If no configuration is set, fallback to displaying all languages (default behavior remains unchanged).

Add languages cache context to the render array for proper cache variation.

✨ Feature request
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States eliasbrat

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024