shadcn.io is not affiliated with official shadcn/ui
Localization Settings Block for React
A localization settings panel: a table of languages with translation progress, a Default radio, an RTL tag and an On switch, languages to add in the same table, and a fallback chain with Move up and down whose sentence follows its order.
Installation
Overview
Decide which languages a product ships in and what a visitor sees when a string is missing, with this localization panel for React with Base UI. A hairline frame with a plus mark on each corner holds a table of eight languages: each row names the language and its tag with the day it last synced, draws how much of it is translated as a bar with the words under it ("94% translated, 1,166 of 1,240"), and carries a Default radio and a Switch that turns it on or off. Arabic wears an RTL Badge. The default language shows its switch locked on, and a language that has not been added yet sits in the same table with an Add Button, so the table keeps its height. Under it, a fallback chain: pick a language with a Native Select and see the languages tried, in order, when a string is missing, with Move up and Move down and a sentence worked out from the order ("A missing string in fr-CA shows fr, then en."). A language that is complete makes the ones after it unreachable, and the block says so. The last band counts unsaved changes beside a Shine Button to save them and an outline Button to discard them. On a phone each language becomes a card. It's built from Switch, Native Select, Badge, Button, Shine Button and Guides, with a CSS entrance only. For a translation tool, a CMS or any product with more than one language.
FAQ
How do I fill it with my languages and strings?
Edit the constants at the top. TOTAL is how many strings the source language has, LANGS names each language by its tag and says whether it reads end to start, and START_ROWS gives each one's translated count, whether it is added and whether it is on. SAVED holds the chosen default and one chain per language. The percentages, the counts, the on-totals in the heading and the sentences under the chain are all worked out from those, so nothing is typed twice.
What can't I do with the default language?
You cannot turn it off: its switch is shown on and locked, with a lock beside it. Choosing another language as the default makes that language the default; if it was off, it is switched on at the same time and the status line says so, and the old default becomes an ordinary language you can turn off. The Default choices are native radios in one group, so the arrow keys move between them.
How does the fallback chain work?
When a string is missing in the chosen language, the product tries the chain's languages in order and shows the first that has it. The sentence lists the languages that would be used. Off languages are skipped, and a language that has every string ends the chain, so anything after it is marked "Never reached": move English above French and the note says French is never reached because English has every string. If every language in the chain is incomplete, a string missing in all of them shows its key. Move up and Move down are named for the language, stay in place at the ends, and say what moved.
What does Add do?
It adds the language to the table, off, with 0% translated, and moves focus to its switch so you can turn it on. Its chain starts as the default language alone. In the demo the new language stays in the page; in your product, create the language on your server first and fill the progress from the response.
What happens when I press Save, and what stays local?
Nothing leaves the page. The block keeps the saved setup and the one being edited, counts how many things differ (switches, the default, added languages and chains) and says so in its status line. Save makes the edited copy the saved one and says so in this demo; Discard puts the saved copy back. To make it real, send the changes to your API in the save handler. Save and Discard are marked aria-disabled rather than disabled while nothing changed, so they keep their place and focus.
Is the table accessible, and how does it look on a phone?
It is a native table with a caption, column headers and the language as each row's header, and every switch and radio is named for its language. The bar is decorative: the words under it carry the same figure. Below the medium breakpoint each row becomes a card with the language over its progress, then Default and On side by side with their words showing. The status line is a polite live region that is present from the start.
Related
- Pro
Language and Region Settings
Appearance and localeA language and region settings panel: two selects over three cells that show what they do, a sort order made by the language's collation, a month marked with the region's first weekday, and units with a worked example.
- Pro
A team intranet's profile page with its language and region dialog shown open: a Language tab with a searchable list of eight languages, a Region tab with country, first day of the week and clock, and a live preview that reformats a sample date, time, number and amount with Intl.
- Pro
Cache Policy Settings
Domains and deliveryAn ordered table of cache rules where first match wins: each path pattern has a freshness bar, how long a copy stays fresh and how long a stale one may be served, a count of the cached paths it really claims, and a purge that counts what it would clear.
- Pro
Language Selector Footer
PreferencesA footer for a meeting-notes tool whose segmented control (EN, FR, DE, ES) rewrites the footer's own words, with three link groups and a legal row.
- Pro
Appearance Settings
Appearance and localeAn appearance settings panel that previews instead of applying: a drawn app window that wears the choices, theme and contrast cards with a drawn thumbnail each, a text-size slider with a sample sentence and a reduce motion switch with a replay.
- Pro
Brand Asset Settings
Appearance and localeA logo check panel: Paper and Ink tiles showing a drawn lettermark at true size with its clear space in hairlines and its contrast worked out from the hex values, a Full, Mark or Mono toggle, a size slider that warns below 24 px, and a four-colour palette with Copy.