@i18n-micro/solid
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
I18nLink
function I18nLink(props: I18nLinkProps): JSX.Element
See I18nLinkProps
I18nProvider
function I18nProvider(props: ParentProps<I18nProviderProps>): JSX.Element
I18nSwitcher
function I18nSwitcher(props: I18nSwitcherProps): JSX.Element
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
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)
}
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
useI18n() object: one per provider, signals do the rest.I18nGroupProps
interface I18nGroupProps extends Omit<JSX.HTMLAttributes<HTMLDivElement>, 'children'>
I18nLinkProps
interface I18nLinkProps extends JSX.AnchorHTMLAttributes<HTMLAnchorElement>
I18nProviderProps
interface I18nProviderProps
I18nRoutingStrategy
Routing strategy interface for i18n Implement this interface to integrate with any router library Matches Vue package interface for consistency
interface I18nRoutingStrategy
I18nSwitcherProps
interface I18nSwitcherProps extends JSX.HTMLAttributes<HTMLDivElement>
disabled: true in locale config. Disabled locales are omitted from dropdown items.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
{name} placeholders. Beats a param of the same name.RouteTarget
Where a link or a switch goes.
type RouteTarget = string | {
path?: string;
}
SolidI18nOptions
type SolidI18nOptions = I18nOptions
See I18nOptions
UseI18nOptions
interface UseI18nOptions
UseI18nReturn
type UseI18nReturn = ReturnType<typeof createApi>
Re-exports
Declared in another package of this repository and documented on its page.
- From
@i18n-micro/core:defaultPlural·interpolate·FormatService - From
@i18n-micro/types:CleanTranslation·Getter·Locale·LocaleCode·ModuleOptions·Params·PluralFunc·TranslationKey·Translations
@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
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