Welcome to our platform
Start exploring our modern features today.
);
}
```
Behind the scenes, Intlayer builds the dictionary and links the component to its localized content, completely eliminating manual refactoring.
In this case, it generates a `src/App.content.ts` declaration file with the following structure:
```typescript fileName="src/App.content.ts"
import { Dictionary } from "intlayer";
const content = {
key: "app",
content: {
welcomeToOurPlatform: t({ en: "Welcome to our platform" }),
startExploringOurModernFeaturesToday: t({
en: "Start exploring our modern features today.",
}),
},
};
export default content;
```
## AI-Powered Translation with Your Favorite LLM
Once your content is extracted, translating it into dozens of languages should not take days. Intlayer includes a built-in AI translation CLI that integrates directly with OpenAI, Anthropic, DeepSeek, or Mistral using your own API keys:
```bash packageManager="npm"
npx intlayer fill
```
```bash packageManager="pnpm"
pnpm dlx intlayer fill
```
```bash packageManager="yarn"
yarn dlx intlayer fill
```
```bash packageManager="bun"
bunx intlayer fill
```
Configure your locales and AI provider in `intlayer.config.ts`:
```typescript fileName="intlayer.config.ts"
import { Locales, type IntlayerConfig } from "intlayer";
const config: IntlayerConfig = {
internationalization: {
locales: [Locales.ENGLISH, Locales.FRENCH, Locales.SPANISH, Locales.GERMAN],
defaultLocale: Locales.ENGLISH,
},
ai: {
provider: "openai",
model: "gpt-4o-mini",
apiKey: process.env.OPENAI_API_KEY,
applicationContext:
"Modern SaaS application and dashboard built with Vite and React",
},
};
export default config;
```
Running `npx intlayer fill` populates your content declarations with high-quality translations for your configured locales:
```typescript fileName="src/App.content.ts"
import { Dictionary } from "intlayer";
const content = {
key: "app",
content: {
welcomeToOurPlatform: t({
en: "Welcome to our platform",
fr: "Bienvenue sur notre plateforme",
es: "Bienvenido a nuestra plataforma",
de: "Willkommen auf unserer Plattform",
}),
startExploringOurModernFeaturesToday: t({
en: "Start exploring our modern features today.",
fr: "Découvrez nos fonctionnalités modernes dès aujourd'hui.",
es: "Comience a explorar nuestras funciones modernas hoy.",
de: "Entdecken Sie noch heute unsere modernen Funktionen.",
}),
},
};
export default content;
```
Because Intlayer provides high-level `applicationContext` to the LLM, generated translations preserve technical nuance, brand tone, and grammatical context far better than traditional generic translation tools.
To verify that no strings were missed before deploying to production:
```bash
npx intlayer test
```
## Vite Integration and Provider Setup
Integrating Intlayer into Vite requires adding the plugin to `vite.config.ts` and wrapping your root component with `IntlayerProvider`:
```typescript fileName="vite.config.ts"
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react-swc";
import { intlayer } from "vite-intlayer";
export default defineConfig({
plugins: [react(), intlayer()],
});
```
> Since Intlayer v9, the compiler is bundled directly into the `intlayer()` plugin and activates automatically once `compiler.enabled` is configured in `intlayer.config.ts`.
Wrap your application with `IntlayerProvider` in your root component:
```tsx fileName="src/App.tsx"
import { FC } from "react";
import { IntlayerProvider } from "react-intlayer";
import { MainContent } from "./MainContent";
const App: FC = () => {
return (