Quick Start (SolidJS)
-
Install packages
Terminal window pnpm add @fluenti/core @fluenti/solidpnpm add -D @fluenti/cli @fluenti/vite-plugin -
Configure Vite
vite.config.ts import { defineConfig } from 'vite'import solidPlugin from 'vite-plugin-solid'import fluenti from '@fluenti/vite-plugin'export default defineConfig({plugins: [solidPlugin(),fluenti({ framework: 'solid' }),],}) -
Create
fluenti.config.tsfluenti.config.ts export default {sourceLocale: 'en',locales: ['en', 'zh-CN'],catalogDir: './locales',format: 'po',include: ['./src/**/*.{tsx,ts}'],compileOutDir: './src/locales/compiled',} -
Write your component — use
t()with source textsrc/Home.tsx import { useI18n } from '@fluenti/solid'export function Home() {const { t, setLocale } = useI18n()return (<div><h1>{t('Welcome to my app')}</h1><p>{t('Hello, {name}!', { name: 'World' })}</p><button onClick={() => setLocale('en')}>English</button><button onClick={() => setLocale('zh-CN')}>中文</button></div>)} -
Extract messages
Terminal window npx fluenti extractThis scans your source files and generates catalog files in
./locales/. -
Add translations
Open
locales/zh-CN.poand fill inmsgstrfields:msgid "Welcome to my app"msgstr "欢迎使用我的应用"msgid "Hello, {name}!"msgstr "你好,{name}!" -
Compile messages
Terminal window npx fluenti compile -
Initialize from compiled output
src/App.tsx import { I18nProvider } from '@fluenti/solid'import { Home } from './Home'import en from './locales/compiled/en'import zhCN from './locales/compiled/zh-CN'export function App() {return (<I18nProviderlocale="en"fallbackLocale="en"messages={{ en, 'zh-CN': zhCN }}><Home /></I18nProvider>)}
Key differences from Vue
Section titled “Key differences from Vue”- Uses
<I18nProvider>instead of a plugin - Signals (
name()) instead of refs (name.value) - JSX instead of templates — use
t()directly in JSX expressions - Naturally reactive —
t()reads thelocale()signal, so JSX auto-tracks it
Rich text with <Trans>
Section titled “Rich text with <Trans>”<Trans>Click <a href="/next">here</a> to continue.</Trans><Trans>This is <strong>important</strong> information.</Trans>Plurals with <Plural>
Section titled “Plurals with <Plural>”<Plural value={count()} zero="No items" one="# item" other="# items" />