LocaleSwitcher

Molecule

A language picker for public pages. Options are links when they have an href (a native details menu, so it works without JavaScript) or buttons when they do not. Names are shown in their own language with lang and dir set, the current locale is marked in text, and a locale whose page falls back to another language says so. Not the flag dropdown LanguageSwitcher of the common domain: no flag assets and no i18n dependency.

Menu of links

Code
<LocaleSwitcher locales={locales} current="en" />

Inline buttons

Preview
Code
<LocaleSwitcher variant="inline" locales={localesWithoutHref} current="en" onChange={(code) => setLocale(code)} />

Right to left

Code
<div dir="rtl"><LocaleSwitcher locales={locales} current="ar" /></div>
Sourcemodules/ui/LocaleSwitcher/index.tsx