Pages
Components
Everything void-fbtee gives an app's pages, from void-fbtee/react: its components and hooks, what each is for, each at work, and the line that uses it.
Components
I18nProvider
Goes once around the app, in the root layout, so every page's strings are in its language from the first render.
<I18nProvider>Link
Void's link, with the page's language in the address it goes to.
<Link href={routeUrl("/[lang]/events")} className={linkClass}>Formatted
Text formatted while rendering, such as a date, kept as the server wrote it, since each browser formats a little differently.
<Formatted>{languageName(locale)}</Formatted>InLanguage
Part of a page in another language, with its own lang and direction, and worded by the reader's gender where the language needs it.
- أنت مسجَّل.
- คุณจองแล้ว
<InLanguage locale={locale} gender={gender}>LanguagePicker
One control for choosing another language, however many the app has: the reader's own first, then every language, with a search box. It has no look of its own: the app gives it one.
<LanguagePickerThe language picker, two looks
The same component twice, with different class names: the header's look, and a row of pills. Its order, names, links and search are the package's; how it looks is the app's.
English
English
Hooks
useLocale
The page's language, its direction, and the address after the language.
{"locale":"en-US","dir":"ltr","path":"/docs/components"}const { path } = useLocale();useLocales
Every language the app has, from its settings: never a list of its own.
en-US, ar-EG, th-THconst locales = useLocales();useHydrated
False on the server and while the page starts, true after: for what only the browser knows, so the first render matches the server's.
falseconst hydrated = useHydrated();useNow
Now: the server's moment at first, so both render the same, then the browser's clock.
const now = useNow({ updateInterval: 60_000 });useTimeZone
The reader's own time zone, once the browser knows it; none on the server.
—const reader = useTimeZone();useForm
Void's form, posting to the address in the page's language, so its answer and errors are too.
const form = useForm("/[lang]/events/new", {langAttrs
lang and dir for text in a language other than the page's, such as what people post.
<bdi {...langAttrs(event.locale)}>{event.venue}</bdi>