Skip to content
Comvi

Comvi i18n

View .md

Comvi i18n is a small, framework-agnostic library for translating apps: one i18n instance, a binding for React, Next.js, Vue, Nuxt, Svelte or Solid, and t() in your components. Catalogs are plain JSON, inline in your source or served at runtime from the Comvi CDN so a wording change ships without a redeploy.

src/App.tsx
import { useI18n } from '@comvi/react';
export default function App() {
const { t } = useI18n();
return <h1>{t('greeting', { name: 'Alice' })}</h1>;
}

createI18n() returns the i18n instance: the catalogs, the current locale and t(). A binding hands it to components, so useI18n() in React, Vue, Svelte or Solid and getI18n() in a Next.js Server Component read the same instance. A loader and the locale detector are installers: you compose them with .use(), and what you do not compose is not in your bundle. The ICU compiler is the constructor option compiler: icuCompiler, opted into the same way.

flowchart LR
  App["Your components"]
  Binding["Binding<br/>useI18n() / getI18n()"]
  Instance["i18n instance<br/>createI18n()"]
  Inline["Inline catalog<br/>messages: { en: … }"]
  Loader["Loader<br/>.use(cdnLoader({ cdnUrl }))"]
  CDN["Comvi CDN"]

  App --> Binding --> Instance
  Inline --> Instance
  Loader --> Instance
  CDN --> Loader
Components talk to the binding, the binding to the i18n instance. The instance reads its catalog from your source or from a loader; the component does not know which.

Each item has a snippet on Features.

  • Quick start: a translated heading and a locale switch in your framework, five minutes, no account.
  • Important defaults: the behaviours that surprise people, and why each is the default.

The Comvi platform stores the keys, machine-translates new ones and publishes each locale as JSON on a CDN; @comvi/plugin-fetch-loader reads it at runtime and the CLI generates types for t(). None of it is required: the instance works with an inline catalog, and Connect to Comvi is a separate, optional step.

  • Limitations: what the library does not do, with what happens instead.
  • Glossary: i18n instance, binding, catalog, installer, and the other words these pages use.