@jorvel/i18n
ICU-capable i18n primitives — framework-agnostic core + React bindings at @jorvel/i18n/react.
Core
ts
createI18n({ locale, catalogs?, fallbackLocale? }): I18n; // t(), setLocale, load, subscribe
getI18n(opts?): I18n; setI18n(instance): void;
formatMessage(template, values?, locale?): string; // {name} {n, plural} {n, number} {g, select} {d, date}
detectLocale(accept, supported, fallback): string; // Accept-Language (positional)Locale routing
ts
extractLocale(pathname, locales, opts?): { locale: string | null; rest: string };
localizePath(pathname, locale, opts?): string; // '/dashboard' → '/fr/dashboard'
stripLocale(pathname, locales, opts?): string;
buildLocaleHref(...): string;Detection + middleware
ts
negotiateLocale({ supported, default, header?, cookie? }): string;
localeMiddleware({ supported, default, cookieName?, redirectStatus? }):
(ctx) => { type: 'next' } | { type: 'redirect'; to; status };RTL
ts
isRtlLocale(locale): boolean; dirForLocale(locale): 'rtl' | 'ltr';
htmlDirAttrs(locale): { lang: string; dir: 'rtl' | 'ltr' };React (@jorvel/i18n/react)
ts
<I18nProvider i18n={...}>; useI18n(); useT(); useLocale(); <Trans id values />