Askr documentation
Generated API snapshot

@askrjs/i18n

Exports from the declarations published in @askrjs/i18n. Signatures reflect the published artifact.

Exports

This entrypoint publishes 7 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.

applyLocaleAttributestype

applyLocaleAttributes: (target: LocaleAttributeTarget, attributes: LocaleAttributes) => void

Apply locale attributes to an explicit DOM target such as document.documentElement.

Catalogtype

Catalog: Readonly<Record<string, CatalogMessage>>

Read-only map of message keys to typed message functions.

CatalogMessagetype

CatalogMessage: (...args: Args) => string

Typed message function in a locale catalog.

createI18ntype

createI18n: <const SourceLocale extends string, const Catalogs extends Record<SourceLocale, Catalog>>(sourceLocale: SourceLocale, catalogs: Catalogs & ValidCatalogs<Catalogs, SourceLocale>) => I18n<Catalogs>

Creates an application-owned internationalization service. Catalog values are ordinary typed TypeScript functions. Locale selection is intentionally left to the application and installed lexically through Scope.

I18nHydrationtype

I18nHydration: Readonly<{
  /** Snapshot schema version. */
  version: 1;
  /** Active locale. */
  locale: Locale;
  /** Text direction for the locale. */
  dir: TextDirection;
  /** Catalog selected for the locale. */
  catalog: Locale;
}>

Serializable locale state for SSR hydration.

localeAttributestype

localeAttributes: <const Locale extends string>(locale: Locale, direction?: TextDirection) => LocaleAttributes<Locale>

Build semantic HTML attributes for a document or nested locale boundary.

resolveTextDirectiontype

resolveTextDirection: (locale: string, override?: TextDirection) => TextDirection

Resolve a locale's default text direction, allowing an explicit application override.