Skip to content

Add country-qualifier dedup to language switcher#555

Merged
ddon merged 1 commit into
BeamLabEU:devfrom
alexdont:dev
May 20, 2026
Merged

Add country-qualifier dedup to language switcher#555
ddon merged 1 commit into
BeamLabEU:devfrom
alexdont:dev

Conversation

@alexdont
Copy link
Copy Markdown
Contributor

When only one dialect of a base language is enabled, the switcher now renders the bare language name ("German", "Chinese") instead of the configured "German (Germany)" / "Chinese (Simplified)". Multi-dialect bases (e.g. en-US + en-GB) keep the qualifier so entries remain distinguishable. Restores the bare-label rendering lost in d1c2d57 when the switcher rewrote to one-row-per-dialect.

Implementation lives in PhoenixKitWeb.Components.Core.LanguageSwitcher (the frontend switcher) as the canonical home — dedupe_names/1 is public and called from AdminNav and UserDashboardNav so all language menus share one rule. Bare-name derivation reuses the historical extract_base_language_name/1 string parse
("Spanish (Mexico)" -> "Spanish"); sibling count comes from DialectMapper.group_dialects_by_base/1.

When only one dialect of a base language is enabled, the switcher
now renders the bare language name ("German", "Chinese") instead
of the configured "German (Germany)" / "Chinese (Simplified)".
Multi-dialect bases (e.g. en-US + en-GB) keep the qualifier so
entries remain distinguishable. Restores the bare-label rendering
lost in d1c2d57 when the switcher rewrote to one-row-per-dialect.

Implementation lives in PhoenixKitWeb.Components.Core.LanguageSwitcher
(the frontend switcher) as the canonical home — `dedupe_names/1` is
public and called from AdminNav and UserDashboardNav so all language
menus share one rule. Bare-name derivation reuses the historical
`extract_base_language_name/1` string parse
("Spanish (Mexico)" -> "Spanish"); sibling count comes from
`DialectMapper.group_dialects_by_base/1`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ddon ddon merged commit 7201cc9 into BeamLabEU:dev May 20, 2026
ddon pushed a commit that referenced this pull request May 20, 2026
#554 ships the PR #552 locale-prefix follow-ups (login-redirect gate,
LocalePath dedup, redirect_invalid_locale swap-vs-strip, 22 new tests).
Verdict: ship. Notes are nitpicks — double prefixless_primary? read in
redirect_invalid_locale, moduledoc "three rules" / four-item list,
mix_task_context? sentinel duplicated between Languages + Routes.

#555 restores the bare-label rendering for single-dialect bases in the
language switcher (and inherits it into admin/user dashboard nav via
the public dedupe_names/1). Verdict: ship. Notes are nitpicks —
unrun doctests on the new helpers, the dedup rule is duplicated between
display_name_for/3 and dedupe_one_name/2, extract_base_language_name/1
returns "" on "" input.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ddon pushed a commit that referenced this pull request May 20, 2026
Rolls up PR #554 (locale-prefix follow-ups — login regression fix,
sitemap source dedup, redirect_invalid_locale swap-vs-strip, 22 new
tests), PR #555 (language switcher country-qualifier dedup), and the
etcher 0.3 → 0.4 / fresco 0.5.2 → 0.5.3 bumps.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants