URL path-prefix locale routing. Enable via mountApp({ i18n: { locales, defaultLocale } }) or the otfw.configi18n block. Messages and formatters live in @opentf/web-i18n.
Export
Signature
Description
router.locale
string | null
Active locale (reactive); null when i18n is off.
localizePath(path, locale?)
(string, string?) => string
Prefix path for locale — default locale stays bare, any existing prefix is replaced. Defaults to the active locale.
setLocale(locale)
(string) => void
Set router.locale without navigating (previews/tests; routed apps derive it from the URL).
configureI18n(config)
({ locales, defaultLocale }) => void
Register the locales (what mountApp({ i18n }) calls).
resolveLocale(pathname)
(string) => { locale, path }
Split a path into its locale and the locale-agnostic route (strips a non-default prefix).
Components & utilities
Export
Description
ErrorBoundary
Catches render/mount errors in its subtree and shows a fallback — see Error boundaries.
Portal
Renders children into a different DOM location — see Portal.
RawHtml
Injects a trusted HTML string.
createContext(default)
Context token with a fallback when no provider is found.
ContextProvider
<ContextProvider context={…} value={…}> — publishes value to descendants.
readContext(ctx)
Returns the resolved signal (.value); $context lowers to this in components.