Skip to content

@i18n-micro/astro

56 exports across 6 entry points. Generated from the API snapshot that pnpm run api:surface checks against the TypeScript sources.

@i18n-micro/astro

ts
import { /* … */ } from '@i18n-micro/astro'
ExportKindSignature
AstroI18nclass48 members
AstroI18nOptionsinterface9 members
CleanTranslationtypestring | number | boolean | Translations | PluralTranslations | null
createAstroRouterAdapterfunction(locales: Locale[], defaultLocale: string, getCurrentUrl?: () => URL) => I18nRoutingStrategy
createI18nfunction(options: AstroI18nOptions) => AstroI18n
createI18nMiddlewarefunction(options: I18nMiddlewareOptions) => MiddlewareHandler
defaultPluralconstPluralFunc
detectLocalefunction(pathname: string, cookies: { get: (name: string) => { value: string; } | undefined; }, headers: Headers, defaultLocale: string, locales: string[], localeCookie?: string | null, routingStrategy?: I18nRoutingStrategy | null) => string
FormatServiceclass19 members
getDefaultLocalefunction(astro: AstroGlobal) => string
getGlobalRoutingStrategyfunction() => I18nRoutingStrategy | null
getI18nfunction(astro: AstroGlobal) => AstroI18n
getI18nPropsfunction(astro: AstroGlobal, keys?: string[]) => I18nClientProps
getLocalefunction(astro: AstroGlobal) => string
getLocalesfunction(astro: AstroGlobal) => Locale[]
Gettertype(key: TranslationKey, params?: Record<string, string | number | boolean>, defaultValue?: string) => unknown
I18nClientPropsinterface4 members
i18nIntegrationfunction(options: I18nIntegrationOptions) => AstroIntegration
I18nIntegrationOptionsinterface52 members
I18nMiddlewareOptionsinterface7 members
I18nRoutingStrategyinterface10 members
interpolatefunction(template: string, params: Params) => string
LoadedTranslationsinterface2 members
loadTranslationsFromDirfunction(options: LoadTranslationsOptions) => LoadedTranslations
loadTranslationsIntoI18nfunction(i18n: { addTranslations: (locale: string, translations: Translations, merge?: boolean) => void; addRouteTranslations: (locale: string, routeName: string, translations: Translations, merge?: boolean) => void; }, options: LoadTranslationsOptions) => void
LoadTranslationsOptionsinterface3 members
Localeinterface11 members
LocaleCodetypestring
LocaleHeadOptionsinterface4 members
LocaleHeadResultinterface3 members
ParamstypeRecord<string, string | number | boolean>
PluralFunctype(key: TranslationKey, count: number, params: Params, locale: string, getter: Getter) => string | null
runWithRoutingStrategyfunction<T>(strategy: I18nRoutingStrategy | null, fn: () => T) => T
setGlobalRoutingStrategyfunction(strategy: I18nRoutingStrategy | null) => void
Translationsinterface1 members
useI18nfunction(astro: AstroGlobal) => { locale: string; defaultLocale: string; locales: Locale[]; t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation; ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeName?: string) => string; tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string; tn: { (value: number, options?: Intl.NumberFormatOptions): string; (value: number, key: string, overrides?: Intl.NumberFormatOptions): string; (value: number, key: string, locale: string, overrides?: Intl.NumberFormatOptions): string; }; td: { (value: Date | number | string, options?: Intl.DateTimeFormatOptions): string; (value: Date | number | string, key: string, overrides?: Intl.DateTimeFormatOptions): string; (value: Date | number | string, key: string, locale: string, overrides?: Intl.DateTimeFormatOptions): string; }; tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; has: (key: TranslationKey, routeName?: string) => boolean; getRoute: () => string; getRouteName: (path?: string) => string; getLocaleFromPath: (path?: string) => string; switchLocalePath: (newLocale: string) => string; localizePath: (path: string, targetLocale?: string) => string; getI18n: () => AstroI18n; getBasePath: (url?: URL) => string; addTranslations: (locale: string, translations: Record<string, unknown>, merge?: boolean) => void; addRouteTranslations: (locale: string, routeName: string, translations: Record<string, unknown>, merge?: boolean) => void; mergeTranslations: (locale: string, routeName: string, translations: Record<string, unknown>) => void; clearCache: () => void; }
useLocaleHeadfunction(astro: AstroGlobal, options?: LocaleHeadOptions) => LocaleHeadResult
AstroI18n — 48 members
MemberType
_currentRouteprivate string
_fallbackLocaleprivate string
_localeprivate string
addRouteTranslations(locale: string, routeName: string, translations: Translations, merge?: boolean) => void
addTranslations(locale: string, translations: Translations, merge?: boolean) => void
clearCache() => void
clone(newLocale?: string) => AstroI18n
cloneStorageprivate (source: TranslationStorage) => TranslationStorage
fallbackLocalestring
formatterFormatService
getCustomMissingHandler?(() => MissingHandler | null) | undefined
getFallbackLocale() => string
getLocale() => string
getMissingContextprotected (routeContext?: unknown) => { locale: string; routeName: string; }
getRoute() => string
getRouteTranslations(locale: string, routeName: string) => Translations | null
has(key: TranslationKey, routeContext?: unknown) => boolean
helper{ hasCache(locale: string, page: string): boolean; getCache(locale: string, routeName: string): Translations | undefined; setCache(_locale: string, _routeName: string, _cache: Map<string, unknown>): void; hasTranslation(locale: string, key: string): boolean; hasPageTranslation(locale: string, routeName: string): boolean; getTranslation<T = unknown>(locale: string, routeName: string, key: string): T | null; loadTranslations(locale: string, data: Translations, routeName?: string): void; setTranslations(locale: string, data: Translations, routeName?: string): void; loadPageTranslations(locale: string, routeName: string, data: Translations): void; mergeTranslation(locale: string, routeName: string, newTranslations: Translations, _force?: boolean): void; clearCache(): void; }
initialMessagesprivate Record<string, Translations>
loadRouteTranslationsCore(locale: string, routeName: string, translations: Translations, merge: boolean) => void
loadTranslationsCore(locale: string, translations: Translations, merge: boolean, routeName?: string) => void
localestring
mergeTranslations(locale: string, routeName: string, translations: Translations) => void
missingHandler?((locale: string, key: string, routeName: string) => void) | undefined
missingWarnboolean
new(options: AstroI18nOptions): AstroI18n
onTranslationsChangedprotected () => void
pluralFuncPluralFunc
resolveDateTimeFormatArgsprivate any
resolveHasprotected (key: TranslationKey, routeContext?: unknown) => boolean
resolveLookupprotected (key: TranslationKey, routeContext?: unknown) => unknown | null
resolveNumberFormatArgsprivate any
resolveRouteNameprotected (routeContext?: unknown) => string
resolveTranslations(routeContext?: unknown) => Translations
resolveTranslationTreeprotected (lower: Record<string, unknown>, upper: Record<string, unknown>) => Translations
setRoute(routeName: string) => void
setTranslation(key: TranslationKey, value: unknown) => void
storageTranslationStorage
t(key: TranslationKey, params?: Params, defaultValue?: string | null, routeContext?: unknown) => CleanTranslation
tc(key: TranslationKey, count: number | Params, defaultValue?: string) => string
td{ (value: Date | number | string, options?: Intl.DateTimeFormatOptions): string; (value: Date | number | string, key: string, overrides?: Intl.DateTimeFormatOptions): string; (value: Date | number | string, key: string, locale: string, overrides?: Intl.DateTimeFormatOptions): string; }
tdr(value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string
tn{ (value: number, options?: Intl.NumberFormatOptions): string; (value: number, key: string, overrides?: Intl.NumberFormatOptions): string; (value: number, key: string, locale: string, overrides?: Intl.NumberFormatOptions): string; }
touchprotected () => void
ts(key: TranslationKey, params?: Params, defaultValue?: string, routeContext?: unknown) => string
warnDevprotected (message: string) => void
warnMissingprotected (key: TranslationKey, routeContext?: unknown) => void
warnMissingFormatprotected (kind: "number" | "datetime", key: string, locale: string) => void
AstroI18nOptions — 9 members
MemberType
_storage?TranslationStorage | undefined
datetimeFormats?DateTimeFormatsConfig | undefined
fallbackLocale?string | undefined
localestring
messages?Record<string, Translations> | undefined
missingHandler?((locale: string, key: string, routeName: string) => void) | undefined
missingWarn?boolean | undefined
numberFormats?NumberFormatsConfig | undefined
plural?PluralFunc | undefined
FormatService — 19 members
MemberType
clearCache() => void
dateCacheprivate any
datetimeFormatsprivate any
formatDate(value: Date | number | string, locale: string, options?: Intl.DateTimeFormatOptions) => string
formatNumber(value: number, locale: string, options?: Intl.NumberFormatOptions) => string
formatRelativeTime(value: Date | number | string, locale: string, options?: Intl.RelativeTimeFormatOptions) => string
getDateTimeFormats() => DateTimeFormatsConfig
getDateTimeFormatter(locale: string, options?: Intl.DateTimeFormatOptions) => Intl.DateTimeFormat
getNumberFormats() => NumberFormatsConfig
getNumberFormatter(locale: string, options?: Intl.NumberFormatOptions) => Intl.NumberFormat
getRelativeTimeFormatter(locale: string, options?: Intl.RelativeTimeFormatOptions) => Intl.RelativeTimeFormat
new(options?: FormatServiceOptions | undefined): FormatService
numberCacheprivate any
numberFormatsprivate any
relativeCacheprivate any
resolveDateTimeFormat(locale: string, key: string) => Intl.DateTimeFormatOptions | undefined
resolveNumberFormat(locale: string, key: string) => Intl.NumberFormatOptions | undefined
setDateTimeFormats(formats: DateTimeFormatsConfig) => void
setNumberFormats(formats: NumberFormatsConfig) => void
I18nClientProps — 4 members
MemberType
currentRoutestring
fallbackLocalestring
localestring
translationsRecord<string, Translations>
I18nIntegrationOptions — 52 members
MemberType
apiBaseClientHost?string | undefined
apiBaseServerHost?string | undefined
apiBaseUrl?string | undefined
autoDetect?boolean | undefined
autoDetectLanguage?boolean | undefined
autoDetectPath?string | undefined
cacheMaxSize?number | undefined
cacheTtl?number | undefined
canonicalQueryWhitelist?string[] | undefined
components?boolean | undefined
customRegexMatcher?string | RegExp | undefined
dateBuild?string | number | undefined
datetimeFormats?Record<string, Record<string, Intl.DateTimeFormatOptions>> | undefined
debug?boolean | undefined
defaultLocale?string | undefined
define?boolean | undefined
disablePageLocales?boolean | undefined
disableWatcher?boolean | undefined
excludePatterns?(string | RegExp)[] | undefined
experimental?Record<string, unknown> | undefined
fallbackLocale?string | undefined
globalLocaleRoutes?GlobalLocaleRoutes
hmr?boolean | undefined
hooks?boolean | undefined
hreflangBaseLanguage?boolean | undefined
httpCacheDuration?number | undefined
localestring
localeCookie?string | null | undefined
locales?Locale[] | undefined
localizedRouteNamePrefix?string | undefined
messages?Record<string, Record<string, unknown>> | undefined
meta?boolean | undefined
metaBaseUrl?string | undefined
metaTrustForwardedHost?boolean | undefined
metaTrustForwardedProto?boolean | undefined
missingHandler?((locale: string, key: string, routeName: string) => void) | undefined
missingWarn?boolean | undefined
noPrefixRedirect?boolean | undefined
numberFormats?Record<string, Record<string, Intl.NumberFormatOptions>> | undefined
plugin?boolean | undefined
plural?PluralFunc | undefined
redirects?boolean | undefined
redirectToDefault?boolean | undefined
routeDisableMeta?Record<string, boolean | string[]> | undefined
routeLocales?Record<string, string[]> | undefined
routesLocaleLinks?{ [key: string]: string; } | undefined
routingStrategy?I18nRoutingStrategy | undefined
serverTranslationPreload?boolean | undefined
strategy?Strategies | undefined
translationDir?string | undefined
translationPayloads?TranslationPayloadOptions | undefined
types?boolean | undefined
I18nMiddlewareOptions — 7 members
MemberType
autoDetect?boolean | undefined
defaultLocalestring
i18nAstroI18n
localeObjects?Locale[] | undefined
localesstring[]
redirectToDefault?boolean | undefined
routingStrategy?I18nRoutingStrategy | undefined
I18nRoutingStrategy — 10 members
MemberType
getCurrentPath() => string
getLocaleFromPath?((path: string, defaultLocale: string, locales: string[]) => string) | undefined
getRoute?(() => { fullPath: string; query: Record<string, unknown>; }) | undefined
getRouteName?((path: string, locales: string[]) => string) | undefined
localizePath?((path: string, locale: string, locales: string[], defaultLocale?: string) => string) | undefined
push?((target: { path: string; }) => void) | undefined
removeLocaleFromPath?((path: string, locales: string[]) => string) | undefined
replace?((target: { path: string; }) => void) | undefined
resolvePath?((to: string | { path?: string; }, locale: string) => string | { path?: string; }) | undefined
switchLocalePath?((path: string, newLocale: string, locales: string[], defaultLocale?: string) => string) | undefined
LoadedTranslations — 2 members
MemberType
rootRecord<string, import("packages/types/dist/index").Translations>
routesRecord<string, Record<string, import("packages/types/dist/index").Translations>>
LoadTranslationsOptions — 3 members
MemberType
disablePageLocales?boolean | undefined
rootDir?string | undefined
translationDirstring
Locale — 11 members, identical to [`Locale`](/api/packages/types).
LocaleHeadOptions — 4 members
MemberType
addDirAttribute?boolean | undefined
addSeoAttributes?boolean | undefined
baseUrl?string | undefined
hreflangBaseLanguage?boolean | undefined
LocaleHeadResult — 3 members
MemberType
htmlAttrs{ lang?: string; dir?: "ltr" | "rtl" | "auto"; }
link{ rel: string; href: string; hreflang?: string; }[]
meta{ property: string; content: string; }[]
Translations — 1 members, identical to [`Translations`](/api/packages/types). ## `@i18n-micro/astro/client`
ts
import { /* … */ } from '@i18n-micro/astro/client'
ExportKindSignature
createI18nStorefunction(props: I18nClientProps) => Writable<I18nState>
hasTranslationfunction(state: I18nState, key: string, routeName?: string) => boolean
I18nProviderfunction({ children, value }: { children: React.ReactNode; value: I18nClientProps; }) => React.ReactElement
I18nProviderPreactconst({ children, value }: { children: ComponentChildren; value: I18nClientProps; }) => import("preact/src/index").VNode<{ value: I18nState | null; children?: ComponentChildren; }>
I18nStateinterface4 members
provideI18nfunction(props: I18nClientProps) => Ref<I18nState>
translatefunction(state: I18nState, key: string, params?: Params, defaultValue?: string | null, routeName?: string) => string | number | boolean | Translations | null
useAstroI18nPreactfunction() => { t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation; ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeName?: string) => string; tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string; tn: (value: number, options?: Intl.NumberFormatOptions) => string; td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; has: (key: TranslationKey, routeName?: string) => boolean; locale: string; fallbackLocale: string; currentRoute: string; getRoute: () => string; }
useAstroI18nReactfunction() => { t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation; ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeName?: string) => string; tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string; tn: (value: number, options?: Intl.NumberFormatOptions) => string; td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; has: (key: TranslationKey, routeName?: string) => boolean; locale: string; fallbackLocale: string; currentRoute: string; getRoute: () => string; }
useAstroI18nSveltefunction(store: Writable<I18nState>) => { store: Writable<I18nState>; t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation; ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeName?: string) => string; tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string; tn: (value: number, options?: Intl.NumberFormatOptions) => string; td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; has: (key: TranslationKey, routeName?: string) => boolean; readonly locale: string; readonly fallbackLocale: string; readonly currentRoute: string; setLocale: (locale: string) => void; setRoute: (routeName: string) => void; getRoute: () => string; }
useAstroI18nVuefunction() => { t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation; ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeName?: string) => string; tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string; tn: (value: number, options?: Intl.NumberFormatOptions) => string; td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; has: (key: TranslationKey, routeName?: string) => boolean; locale: import("vue/dist/vue").WritableComputedRef<string, string>; fallbackLocale: import("vue/dist/vue").ComputedRef<string>; currentRoute: import("vue/dist/vue").WritableComputedRef<string, string>; setLocale: (locale: string) => void; setRoute: (routeName: string) => void; getRoute: () => string; }

I18nState — 4 members, identical to I18nClientProps above.

@i18n-micro/astro/client/preact

ts
import { /* … */ } from '@i18n-micro/astro/client/preact'
ExportKindSignature
I18nProviderconst({ children, value }: { children: ComponentChildren; value: I18nClientProps; }) => import("preact/src/index").VNode<{ value: I18nState | null; children?: ComponentChildren; }>
useAstroI18nfunction() => { t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation; ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeName?: string) => string; tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string; tn: (value: number, options?: Intl.NumberFormatOptions) => string; td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; has: (key: TranslationKey, routeName?: string) => boolean; locale: string; fallbackLocale: string; currentRoute: string; getRoute: () => string; }

@i18n-micro/astro/client/react

ts
import { /* … */ } from '@i18n-micro/astro/client/react'
ExportKindSignature
I18nProviderfunction({ children, value }: { children: React.ReactNode; value: I18nClientProps; }) => React.ReactElement
useAstroI18nfunction() => { t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation; ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeName?: string) => string; tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string; tn: (value: number, options?: Intl.NumberFormatOptions) => string; td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; has: (key: TranslationKey, routeName?: string) => boolean; locale: string; fallbackLocale: string; currentRoute: string; getRoute: () => string; }

@i18n-micro/astro/client/svelte

ts
import { /* … */ } from '@i18n-micro/astro/client/svelte'
ExportKindSignature
createI18nStorefunction(props: I18nClientProps) => Writable<I18nState>
useAstroI18nfunction(store: Writable<I18nState>) => { store: Writable<I18nState>; t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation; ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeName?: string) => string; tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string; tn: (value: number, options?: Intl.NumberFormatOptions) => string; td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; has: (key: TranslationKey, routeName?: string) => boolean; readonly locale: string; readonly fallbackLocale: string; readonly currentRoute: string; setLocale: (locale: string) => void; setRoute: (routeName: string) => void; getRoute: () => string; }

@i18n-micro/astro/client/vue

ts
import { /* … */ } from '@i18n-micro/astro/client/vue'
ExportKindSignature
provideI18nfunction(props: I18nClientProps) => Ref<I18nState>
useAstroI18nfunction() => { t: (key: TranslationKey, params?: Params, defaultValue?: string | null, routeName?: string) => CleanTranslation; ts: (key: TranslationKey, params?: Params, defaultValue?: string, routeName?: string) => string; tc: (key: TranslationKey, count: number | Params, defaultValue?: string) => string; tn: (value: number, options?: Intl.NumberFormatOptions) => string; td: (value: Date | number | string, options?: Intl.DateTimeFormatOptions) => string; tdr: (value: Date | number | string, options?: Intl.RelativeTimeFormatOptions) => string; has: (key: TranslationKey, routeName?: string) => boolean; locale: import("vue/dist/vue").WritableComputedRef<string, string>; fallbackLocale: import("vue/dist/vue").ComputedRef<string>; currentRoute: import("vue/dist/vue").WritableComputedRef<string, string>; setLocale: (locale: string) => void; setRoute: (routeName: string) => void; getRoute: () => string; }

Back to all packages · Integration guides

Released under the MIT License.