Skip to content
F fluenti

@fluenti/solid

Provide i18n context to the component tree.

import { I18nProvider } from '@fluenti/solid'
import en from './locales/compiled/en'
import zhCN from './locales/compiled/zh-CN'
<I18nProvider
locale="en"
fallbackLocale="en"
messages={{ en, 'zh-CN': zhCN }}
>
<App />
</I18nProvider>
PropTypeDescription
localestringInitial locale
fallbackLocalestring?Fallback locale
messagesAllMessagesCompiled message catalogs (from fluenti compile)
missing(locale, id) => string?Missing message handler
splittingboolean?Enable code-splitting mode
chunkLoader(locale) => Promise<Messages>?Async locale loader

Access the i18n context from the nearest provider.

import { useI18n } from '@fluenti/solid'
function MyComponent() {
const { t, format, locale, setLocale, d, n, isLoading, preloadLocale } = useI18n()
return <p>{t('Hello, {name}!', { name: 'World' })}</p>
}
PropertyTypeDescription
t(id, values?) => stringTranslate a message
format(message, values?) => stringDirect ICU interpolation without catalog lookup
localeAccessor<string>Current locale (signal)
setLocale(locale) => Promise<void>Change locale (async with splitting)
loadMessages(locale, messages) => voidLoad messages at runtime
getLocales() => string[]Get all loaded locale codes
d(value, style?) => stringFormat a date
n(value, style?) => stringFormat a number
tRaw(message, values?) => string@deprecated Use format() instead
isLoadingAccessor<boolean>Whether a locale chunk is loading
loadedLocalesAccessor<Set<string>>Set of loaded locales
preloadLocale(locale) => voidPreload a locale without switching

Direct ICU interpolation without catalog lookup. Useful for one-off messages or dynamic patterns.

function MyComponent() {
const { format } = useI18n()
return <p>{format('Hello {name}!', { name: 'World' })}</p>
}

Rich text with component interpolation. Globally registered — no import needed.

The default slot is the primary API. The slot content is the source-language message, which is auto-extracted and translated via the catalog:

<Trans>Click <a href="/next">here</a> to continue.</Trans>

You can still use the message prop with components for explicit component mapping:

<Trans
message={t('Click <link>here</link>')}
components={{ link: (props) => <a href="/next">{props.children}</a> }}
/>

Pluralization component. Globally registered — no import needed.

Plural forms are source-language text, auto-extracted and translated via the catalog:

<Plural value={count()} one="# item" other="# items" />

Select component for gender, role, etc. Globally registered — no import needed.

Use the options prop for type-safe select patterns:

<Select value={gender()} options={{ male: 'He', female: 'She' }} other="They" />

Alternatively, pass options as attributes:

<Select value={gender()} male="He" female="She" other="They" />

t() reads the locale() signal internally. In JSX expressions, Solid automatically tracks this dependency. When locale changes, only the specific text nodes that call t() update — the component body does not re-execute.