Skip to content

Extract shared LanguageSwitcher and MultilangForm components - #435

Merged
ddon merged 1 commit into
BeamLabEU:devfrom
mdon:dev
Mar 19, 2026
Merged

Extract shared LanguageSwitcher and MultilangForm components#435
ddon merged 1 commit into
BeamLabEU:devfrom
mdon:dev

Conversation

@mdon

@mdon mdon commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

Add two shared components to replace duplicated language switching UI across entities and publishing modules:

  • LanguageSwitcher: configurable language selector with inline, tabs, and pills variants. Supports status dots, primary indicators, display modes, prefix URLs, accessibility attrs, safe coercion, and dev-time validation for conflicting attrs.

  • MultilangForm: form helpers for multilang translation workflows. Provides mount_multilang, handle_switch_language, translatable_field with error display, skeleton wrapper, and inject_db_field_into_data. Supports both JSONB data and settings translations models via secondary_name/lang_data_key overrides.

Swap all entity forms (data_form, entity_form, data_view) and all publishing templates to use the shared components. Remove the old publishing-specific language_switcher.ex. Add crash-proof rescue blocks to entity data form validate/save handlers.

Includes 86 new component tests covering rendering, display modes, filtering, status dots, interaction modes, coercion, accessibility, error display, and field attribute forwarding.

Add two shared components to replace duplicated language switching UI
across entities and publishing modules:

- LanguageSwitcher: configurable language selector with inline, tabs,
  and pills variants. Supports status dots, primary indicators, display
  modes, prefix URLs, accessibility attrs, safe coercion, and dev-time
  validation for conflicting attrs.

- MultilangForm: form helpers for multilang translation workflows.
  Provides mount_multilang, handle_switch_language, translatable_field
  with error display, skeleton wrapper, and inject_db_field_into_data.
  Supports both JSONB data and settings translations models via
  secondary_name/lang_data_key overrides.

Swap all entity forms (data_form, entity_form, data_view) and all
publishing templates to use the shared components. Remove the old
publishing-specific language_switcher.ex. Add crash-proof rescue
blocks to entity data form validate/save handlers.

Includes 86 new component tests covering rendering, display modes,
filtering, status dots, interaction modes, coercion, accessibility,
error display, and field attribute forwarding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ddon
ddon merged commit 992c365 into BeamLabEU:dev Mar 19, 2026
6 checks passed
ddon added a commit that referenced this pull request Mar 19, 2026
- Precompute show_multilang_tabs assign in mount_multilang/refresh_multilang
  to avoid O(n) length/1 calls on every render
- Replace O(n²) Enum.at/2 lookup in language_switcher loop with precomputed
  MapSet of divider indices
- Consolidate preserve_primary_fields into shared MultilangForm helper,
  removing duplicate from data_form.ex
- Add PR #435 review

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ddon added a commit that referenced this pull request Mar 19, 2026
Co-Authored-By: Claude Opus 4.6 (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