PhoenixKit.Modules.Publishing.Web.Components.LanguageSwitcher (phoenix_kit v1.7.33)
Copy Markdown View SourceUnified language switcher component for publishing posts.
Displays available languages as a compact inline list with status indicators. Flexible enough for admin interfaces (with status dots) and public pages (links only).
Display Format
Admin mode: ● EN | ● FR | ○ ES
- Green dot (●): Published
- Yellow dot (●): Draft
- Gray dot (●): Archived
- Empty dot (○): No translation exists
Public mode: EN | FR | ES
- No status indicators
- Only shows languages with published translations
Examples
# Admin: publishing listing with edit links and status indicators
<.publishing_language_switcher
languages={@languages}
current_language="en"
on_click="switch_language"
show_status={true}
/>
# Admin: editor with switch functionality
<.publishing_language_switcher
languages={@languages}
current_language={@current_language}
on_click="switch_language"
show_status={true}
show_add={true}
/>
# Public: post page with translation links
<.publishing_language_switcher
languages={@translations}
current_language={@current_language}
show_status={false}
/>
Summary
Functions
Renders a compact inline language switcher.
Functions
Renders a compact inline language switcher.
Attributes
languages- List of language maps with keys:code,name,status,url,existscurrent_language- Currently active language codeshow_status- Show status indicator dots (default: true)show_add- Show "add" option for missing languages (default: false)show_flags- Show flag emojis (default: false)on_click- Event name for click handler (optional, uses href if not provided)class- Additional CSS classessize- Size variant: :xs, :sm, :md (default: :sm)
Language Map Structure
Each language in the list should have:
code- Language code (e.g., "en", "fr")name- Display name (e.g., "English", "French") - optionalflag- Flag emoji (e.g., "🇺🇸") - optionalstatus- Post status: "published", "draft", "archived", or nil if not existsurl- URL to navigate to (for public mode or href navigation)exists- Boolean, whether translation file exists (default: inferred from status)enabled- Boolean, whether the language is enabled in the Languages module (default: true)known- Boolean, whether the language code is recognized (default: true)
Attributes
languages(:list) (required)current_language(:string) - Defaults tonil.show_status(:boolean) - Defaults totrue.show_add(:boolean) - Defaults tofalse.show_flags(:boolean) - Defaults tofalse.on_click(:string) - Defaults tonil.phx_target(:any) - Defaults tonil.class(:string) - Defaults to"".size(:atom) - Defaults to:sm. Must be one of:xs,:sm, or:md.