Docs/API Reference/Packages

@veap/intl

Inspected version: 0.1.3 · Source

2 min read

Inspected version: 0.1.3 · Source →

Locale detection and ICU message formatting with server and client React APIs.

Entry points#

The manifest exports ., /client, /server and /package.json.

  • Root: shared types, client React exports and translation utilities.
  • /server: configuration, locale detection, provider, server I18nProvider, getTranslation, message loading and IntlService.
  • /client: client provider, locale/time-zone hooks, translation hooks and shared message types.

The manifest declares optional peer dependencies on Next.js ^16, React ^19 and React DOM ^19.

Server API#

Observed exports include:

  • getIntlConfig()
  • getSupportedLocales()
  • getDefaultLocale()
  • getDefaultTimeZone()
  • detectLocale(supportedLocales, defaultLocale)
  • getCurrentLocale()
  • getTranslation(localeOverride?, timeZoneOverride?)
  • getMessages(locale, searchDirectories?)
  • registerMessages(locale, messages)
  • registerMessageLoader(loader, priority?)
  • IntlServiceProvider
  • IntlService
  • server I18nProvider

getTranslation() returns a translator function. The actual exported name is singular; do not use getTranslation() unless your own application defines that wrapper. There is no getCurrentLocale() helper in the inspected source snapshot; use getCurrentLocale() from the server entry point.

Client API#

@veap/intl/client exports I18nProvider, useLocale, useSupportedLocales, useTimeZone, useTranslation, and the alias useTranslations. Hooks require the client context provider.

Message and loader contracts#

AbstractIntlMessages is a recursive dictionary. MessageLoaderFn receives a locale and can return messages synchronously or asynchronously. MessageLoaderRecord supports id, load or loader, and priority; higher priorities override lower priorities.

Configuration#

The IntlConfig shape is { default, locales, cookie, timeZone? }. The server config reader merges defaults with the intl section from Veap config and environment variables. The current locale logic checks the configured cookie first, then negotiates Accept-Language, then falls back to the default locale.

Do not assume automatic URL-prefix routing or route-segment parsing; those behaviors are not established by the inspected detection implementation.

veap
Preparing0%