Appearance
Getting Started
This guide will help you set up unplugin-intl-ai in your project.
Installation
Prerequisites
- Node.js 22+
- A package manager: npm, pnpm, or yarn
- An AI model provider (see AI Model Setup for options)
Install the Package
sh
npm install unplugin-intl-aish
pnpm add unplugin-intl-aish
yarn add unplugin-intl-aish
npx jsr add @intl-ai/unpluginFor Next.js Projects
Install the @intl-ai/next package in your Next.js project:
sh
npm install @intl-ai/nextsh
pnpm add @intl-ai/nextsh
yarn add @intl-ai/nextQuick Start
1. Create Configuration File
Create an intl-ai.config.ts file in your project root:
typescript
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
const lmstudio = createOpenAICompatible({
name: "lmstudio",
baseURL: "http://127.0.0.1:1234/v1",
});
export default {
model: lmstudio("qwen3.5-4b-instruct"),
defaultLocale: "en",
locales: ["en", "de", "es", "fr"],
localeDir: "./locales",
};Key Configuration:
model: Your AI model instance (see AI Model Setup for other providers)defaultLocale: The primary language for your applicationlocales: Array of supported language codeslocaleDir: Directory where translation files will be stored
2. Set Up Your Bundler
typescript
import { defineConfig } from "vite";
import intlAi from "@intl-ai/unplugin/vite";
export default defineConfig({
plugins: [intlAi()],
});javascript
const IntlAiPlugin = require("unplugin-intl-ai/webpack");
module.exports = {
plugins: [new IntlAiPlugin()],
};javascript
import IntlAiPlugin from "unplugin-intl-ai/rollup";
export default {
plugins: [IntlAiPlugin()],
};javascript
import { build } from "esbuild";
import IntlAiPlugin from "unplugin-intl-ai/esbuild";
build({
plugins: [IntlAiPlugin()],
});javascript
const IntlAiPlugin = require("unplugin-intl-ai/rspack");
module.exports = {
plugins: [new IntlAiPlugin()],
};javascript
const withIntlAi = require("@intl-ai/next");
module.exports = withIntlAi({
// Your other Next.js config options
});3. Create Directory and Translation Files
Create the directory specified in your config (default: ./locales), then add your first translation file for the default locale:
locales/en.json:
json
{
"greeting": "Hello, {name}!",
"welcome": "Welcome to our application",
"description": "This is a sample translation"
}Supported Bundlers
unplugin-intl-ai works with all major bundlers:
- Vite - Modern, fast build tool
- Webpack - Industry standard bundler
- Rollup - Flexible module bundler
- esbuild - Extremely fast JavaScript bundler
- Rspack - Rust-based bundler (Webpack-compatible)
- Next.js - React framework with Turbopack support
Verify Installation
To verify everything is working:
- Start your development server:
npm run dev,pnpm dev, oryarn dev - Check that your bundler loads without errors and translation files are being processed
- Verify translations render correctly in your application
If you encounter issues, check the AI Model Setup guide to ensure your model provider is configured correctly.