Package APIs

@i18n-micro/solid

Exported API of @i18n-micro/solid, generated from the source.

SolidJS bindings for i18n-micro — primitives, context, and UI components.

Entry points: @i18n-micro/solid, @i18n-micro/solid/router.

@i18n-micro/solid

Components

I18nGroup

function I18nGroup(props: I18nGroupProps): JSX.Element

See I18nGroupProps

function I18nLink(props: I18nLinkProps): JSX.Element

See I18nLinkProps

I18nProvider

function I18nProvider(props: ParentProps<I18nProviderProps>): JSX.Element

See I18nProviderProps

I18nSwitcher

function I18nSwitcher(props: I18nSwitcherProps): JSX.Element

See I18nSwitcherProps

I18nT

function I18nT(props: I18nTProps): JSX.Element

See I18nTProps

Hooks

useI18n

One object per provider; hook options make their own, and win over the provider.

function useI18n(options?: UseI18nOptions): UseI18nReturn

See UseI18nOptions · UseI18nReturn

useI18nContext

function useI18nContext(): SolidI18n

See SolidI18n

useI18nDefaultLocale

function useI18nDefaultLocale(): string | undefined

useI18nLocales

function useI18nLocales(): Locale[] | undefined

See Locale

useI18nRouter

function useI18nRouter(): I18nRoutingStrategy | undefined

See I18nRoutingStrategy

Functions

createI18n

function createI18n(options: SolidI18nOptions): SolidI18n

See SolidI18nOptions · SolidI18n

Classes

SolidI18n

The runtime instance with signals over its store. A translation read tracks the revision, which every change bumps. Reading the locale tracks the locale alone, so createEffect(() => load(locale())) does not wake itself. getLocale() and getRoute() stay plain, as a write reads them too: track with locale and currentRoute.

class SolidI18n extends I18n {
  constructor(options: SolidI18nOptions)
}
readonly localeAccessor
Accessor<string>
readonly routeAccessor
Accessor<string>
protected touch
() => void
Called before every read; adapters use it for reactivity tracking.
locale
string
fallbackLocale
string
currentRoute
string

See I18n · SolidI18nOptions

Constants

I18nContext

const I18nContext: Context<I18nContextValue | undefined>

See I18nContextValue

Types

I18nContextValue

Everything a provider hands down: getters over its props, so they stay reactive.

interface I18nContextValue
readonly i18n
SolidI18n required
readonly locales
Locale[] | undefined required
readonly defaultLocale
string | undefined required
readonly router
I18nRoutingStrategy | undefined required
api
UseI18nReturn
The useI18n() object: one per provider, signals do the rest.

I18nGroupProps

interface I18nGroupProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children'>
prefix
string required
groupClass
string
children
JSX.Element | ((props: { prefix: string; t: (key: string, params?: Record<string, string | number | boolean>) => string; }) => JSX.Element)

I18nLinkProps

interface I18nLinkProps extends JSX.AnchorHTMLAttributes<HTMLAnchorElement>
to
RouteTarget required
localeRoute
(to: RouteTarget, locale?: string) => RouteTarget
activeStyle
JSX.CSSProperties

I18nProviderProps

interface I18nProviderProps
i18n
SolidI18n
Without it, the outer provider's instance.
locales
Locale[]
defaultLocale
string
routingStrategy
I18nRoutingStrategy

I18nRoutingStrategy

Routing strategy interface for i18n Implement this interface to integrate with any router library Matches Vue package interface for consistency

interface I18nRoutingStrategy
getCurrentPath
() => string required
Returns the current path with its query and hash, so a locale switch keeps them. Links compare it by page. Read a signal or a reactive location here and links and the switcher follow it.
linkComponent
string | Component<{ href: string; children?: JSX.Element; style?: JSX.CSSProperties | string; class?: string; [key: string]: unknown; }>
Component to use for rendering links (e.g., RouterLink)
push
(target: { path: string; }) => void required
Function to navigate to another route/locale
replace
(target: { path: string; }) => void required
Function to replace current route
resolvePath
(to: RouteTarget, locale: string) => RouteTarget
Generate path for specific locale
getRoute
() => { fullPath: string; query: Record<string, unknown>; }
(Optional) Get current route object for SEO/Meta tags

I18nSwitcherProps

interface I18nSwitcherProps extends JSX.HTMLAttributes<HTMLDivElement>

I18nTComponent

What fills a {name} placeholder. A function may run per occurrence; one node can only stand in one place.

type I18nTComponent = JSX.Element | (() => JSX.Element)

I18nTProps

interface I18nTProps extends Omit<JSX.HTMLAttributes<HTMLElement>, 'children'>, ResolveTextOptions
tag
string
components
Record<string, I18nTComponent>
Elements for {name} placeholders. Beats a param of the same name.
children
JSX.Element | ((props: { translation: string; }) => JSX.Element)
Replaces the text. As a function it gets the translation, like Vue's default slot.

See ResolveTextOptions

RouteTarget

Where a link or a switch goes.

type RouteTarget = string | {
  path?: string;
}

SolidI18nOptions

type SolidI18nOptions = I18nOptions

See I18nOptions

UseI18nOptions

interface UseI18nOptions
locales
Locale[]
defaultLocale
string

UseI18nReturn

type UseI18nReturn = ReturnType<typeof createApi>

Re-exports

Declared in another package of this repository and documented on its page.

@i18n-micro/solid/router

Also exports, as @i18n-micro/solid does: I18nRoutingStrategy.

Functions

createSolidRouterAdapter

Factory for Solid Router adapter

location is the router's reactive object, so reading the path inside a memo or JSX follows navigation without a signal of its own.

function createSolidRouterAdapter(
  locales: Locale[],
  defaultLocale: string,
  navigate: NavigateFunction,
  location: Location,
): I18nRoutingStrategy
locales
Locale[] required
Array of locale configurations
defaultLocale
string required
Default locale code
navigate
NavigateFunction required
Navigation function from
location
Location required
Location object from

Returns — I18nRoutingStrategy

const RouterRoot: Component = () => {
  const navigate = useNavigate()
  const location = useLocation()
  const routingStrategy = createSolidRouterAdapter(locales, defaultLocale, navigate, location)
  // ...
}

See Locale · I18nRoutingStrategy


Generated from the TypeScript sources and their JSDoc by pnpm run docs:generate. Back to all packages · Integration guides