TL;DR: For localization in Vue, use vue-i18n's Composition API: createI18n({ legacy: false }) plus useI18n() in components. Keep one JSON file per locale, register pluralRules for languages like Polish, lazy-load non-default locales, format with n() and d(), and type keys from your source locale. In Nuxt, let @nuxtjs/i18n handle routing, lazy loading, and hreflang.
Vue makes it easy to add a second language and surprisingly easy to add it badly. A few $t() calls work fine in a demo; the problems show up later, when there are a dozen locales, a few thousand keys, Polish plurals, and a Nuxt app that has to rank in every market. This guide collects the vue-i18n and Nuxt i18n practices that hold up in production, with code written for the current releases: vue-i18n v11 and @nuxtjs/i18n v10.
The Short Answer
Use the Composition API (createI18n({ legacy: false }) plus useI18n()), keep messages in JSON files per locale, lazy-load every locale except the default, format numbers and dates with n() and d() instead of by hand, and type your message keys from the source locale. In Nuxt, let @nuxtjs/i18n own routing, lazy loading, and SEO tags rather than rebuilding them yourself.
Which Versions This Guide Covers
| Package | Current major | What matters |
|---|---|---|
vue-i18n | v11 | Legacy API deprecated (removal planned for v12), tc()/$tc() removed, v-t directive deprecated. v9 and v10 have reached end of life. |
@nuxtjs/i18n | v10 | Ships vue-i18n v11, lazy-loads all locale files, resolves files from the i18n/ directory. |
@intlify/unplugin-vue-i18n | v11 | Precompiles messages and enables SFC <i18n> blocks in Vite and webpack. |
If you are upgrading from vue-i18n v9 or v10, the Composition API code below works on all three versions; the main breaking changes are the removed tc() and the deprecated Legacy API.
1. Set Up vue-i18n with the Composition API
Install the library and, for Vite projects, the bundler plugin:
npm install vue-i18n npm install -D @intlify/unplugin-vue-i18n Create the i18n instance in its own module so components, router guards, and stores can share it:
// src/i18n.ts import { createI18n } from "vue-i18n"; import en from "./locales/en.json"; export const SUPPORTED_LOCALES = ["en", "fr", "de", "pl"] as const; export type AppLocale = (typeof SUPPORTED_LOCALES)[number]; export const i18n = createI18n({ legacy: false, // Composition API mode; the default is still true in v11 locale: "en", fallbackLocale: "en", messages: { en }, missingWarn: import.meta.env.DEV, fallbackWarn: import.meta.env.DEV, }); // src/main.ts import { createApp } from "vue"; import App from "./App.vue"; import { i18n } from "./i18n"; createApp(App).use(i18n).mount("#app"); In components, call useI18n() and use the returned functions in the template:
<script setup lang="ts"> import { useI18n } from "vue-i18n"; const { t, locale } = useI18n(); const props = defineProps<{ name: string }>(); </script> <template> <h1>{{ t("home.greeting", { name: props.name }) }}</h1> <p>{{ t("home.currentLocale", { locale }) }}</p> </template> Why legacy: false matters: createI18n still defaults to the Legacy API in v11, and @intlify/unplugin-vue-i18n tree-shakes the Legacy API out of production builds by default (its compositionOnly option is true). Forgetting the flag gives you an app that works in development and breaks after a build.
Outside components, in router guards, Pinia stores, or API clients, use the global composer directly: i18n.global.t("errors.network") and i18n.global.locale.value. Calling useI18n() outside a component's setup throws.
2. Learn vue-i18n's Message Syntax (It Is Not ICU)
vue-i18n has its own message format. It looks a little like ICU MessageFormat, but plurals and special characters work differently, and ICU strings copied from another project will not render as expected.
{ "home": { "greeting": "Hello, {name}!", "position": "You are number {0} in line", "brand": "Welcome to @:common.appName", "support": "Email support{'@'}example.com" }, "common": { "appName": "Acme" } } - Named interpolation:
{name}, filled witht("home.greeting", { name: "Ada" }). - List interpolation:
{0}, filled witht("home.position", [12]). - Linked messages:
@:common.appNamereuses another key, so a product name lives in one place. - Literal interpolation:
{'@'}outputs a literal character. The characters{,},@,$, and|are part of the syntax, so an email address likesupport@example.comwritten plainly will fail to compile.
For a deeper comparison with the ICU syntax used by next-intl, FormatJS, and most translation platforms, see our ICU MessageFormat guide. If you need real ICU in a Vue app, you can plug a custom message compiler into vue-i18n, but most teams are better off sticking with the native format.
Rich text without v-html
Never put HTML in a message and render it with v-html; translated strings become an XSS vector. Use the built-in <i18n-t> (Translation) component, which maps named placeholders to slots:
{ "signup": { "terms": "By signing up you accept our {link}.", "termsLink": "terms of service" } } <template> <i18n-t keypath="signup.terms" tag="p"> <template #link> <RouterLink to="/terms">{{ t("signup.termsLink") }}</RouterLink> </template> </i18n-t> </template> Translators can move {link} anywhere in the sentence, and the link still renders as a real component.
3. Pluralization: Pipes and Plural Rules
vue-i18n plurals separate the forms with a pipe. The number is available inside the message as {count} or {n}:
{ "cart": { "items": "no items | one item | {count} items" } } t("cart.items", 0); // "no items" t("cart.items", 1); // "one item" t("cart.items", 7); // "7 items" t("cart.items", { count: 7 }, 7); // explicit named value plus plural count Here is the part many teams miss: in vue-i18n v11, the default choice rule is English-shaped. With two forms it picks singular for 1 and plural for everything else; with three forms it treats them as zero, one, and many. That is wrong for Polish, Russian, Czech, Arabic, and many other languages. You must register a rule for each such locale with the pluralRules option. The cleanest way is to build them from Intl.PluralRules, so you rely on CLDR data instead of hand-written modulo arithmetic:
// src/i18n/plural-rules.ts import type { PluralizationRule } from "vue-i18n"; // Order the message forms like CLDR categories: one | few | many | other const CATEGORY_ORDER = ["zero", "one", "two", "few", "many", "other"] as const; export function cldrRule(locale: string): PluralizationRule { const pr = new Intl.PluralRules(locale); const categories = CATEGORY_ORDER.filter((c) => pr.resolvedOptions().pluralCategories.includes(c), ); return (choice, choicesLength) => { const index = categories.indexOf(pr.select(choice) as (typeof categories)[number]); return Math.min(Math.max(index, 0), choicesLength - 1); }; } // src/i18n.ts import { cldrRule } from "./i18n/plural-rules"; export const i18n = createI18n({ legacy: false, locale: "en", fallbackLocale: "en", messages: { en }, pluralRules: { pl: cldrRule("pl"), ru: cldrRule("ru"), ar: cldrRule("ar"), }, }); { "cart": { "items": "{count} produkt | {count} produkty | {count} produktów | {count} produktu" } } With that rule, the Polish message lists its forms in CLDR order (one, few, many, other), so 1 selects "produkt", 3 selects "produkty", and 5 selects "produktów". Write a comment in your translator brief explaining the order for each language, because a pipe-separated string carries no labels. Automatic Intl.PluralRules selection is planned as a breaking change for vue-i18n v12, so check the release notes when you upgrade.
4. Lazy-Load Locale Messages
Bundling every locale into the main chunk means every visitor downloads every language. Ship the default locale eagerly and load the rest on demand with dynamic imports:
// src/i18n/load.ts import { nextTick } from "vue"; import { i18n, type AppLocale } from "../i18n"; const loaded = new Set<AppLocale>(["en"]); export async function setLocale(locale: AppLocale) { if (!loaded.has(locale)) { const messages = await import(`../locales/${locale}.json`); i18n.global.setLocaleMessage(locale, messages.default); loaded.add(locale); } i18n.global.locale.value = locale; document.documentElement.lang = locale; await nextTick(); } Call it from a router guard when the locale lives in the URL:
// src/router.ts router.beforeEach(async (to) => { const locale = to.params.locale as string; if (!SUPPORTED_LOCALES.includes(locale as AppLocale)) { return `/en${to.fullPath}`; } await setLocale(locale as AppLocale); }); Vite turns the template-literal import into one chunk per locale. Keep the locale list explicit and validate the parameter before importing it, so a crafted URL cannot request arbitrary files. Also update the lang attribute (and dir for right-to-left locales); screen readers and browser translation features depend on it. Use valid BCP 47 codes for file names, URLs, and attributes; our locale codes guide covers the rules.

What setLocale() does on a route change: validate, import the locale chunk once, register it, switch.
5. Format Numbers and Dates with n() and d()
vue-i18n wraps Intl.NumberFormat and Intl.DateTimeFormat. Define named presets per locale once, then use them everywhere:
// src/i18n/formats.ts import type { I18nOptions } from "vue-i18n"; export const numberFormats: I18nOptions["numberFormats"] = { en: { currency: { style: "currency", currency: "USD" }, percent: { style: "percent", maximumFractionDigits: 1 }, }, de: { currency: { style: "currency", currency: "EUR" }, percent: { style: "percent", maximumFractionDigits: 1 }, }, }; export const datetimeFormats: I18nOptions["datetimeFormats"] = { en: { short: { year: "numeric", month: "short", day: "numeric" }, long: { dateStyle: "full", timeStyle: "short" }, }, de: { short: { year: "numeric", month: "short", day: "numeric" }, long: { dateStyle: "full", timeStyle: "short" }, }, }; <script setup lang="ts"> import { useI18n } from "vue-i18n"; const { n, d } = useI18n(); const props = defineProps<{ total: number; currency: string; createdAt: Date }>(); </script> <template> <p>{{ d(props.createdAt, "short") }}</p> <!-- the preset supplies the style; the order supplies the currency --> <p>{{ n(props.total, { key: "currency", currency: props.currency }) }}</p> </template> Pass both objects to createI18n as numberFormats and datetimeFormats. One trap: a preset that hard-codes currency: "EUR" for German converts nothing; it only changes the symbol. If amounts come in different currencies, take the currency from the data, as above. The underlying Intl behavior is covered in our JavaScript Intl API guide.
6. Use SFC <i18n> Blocks Sparingly
With @intlify/unplugin-vue-i18n, a single-file component can carry its own messages in an <i18n> custom block:
// vite.config.ts import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import VueI18nPlugin from "@intlify/unplugin-vue-i18n/vite"; import { fileURLToPath } from "node:url"; export default defineConfig({ plugins: [ vue(), VueI18nPlugin({ include: fileURLToPath(new URL("./src/locales/**", import.meta.url)), }), ], }); <script setup lang="ts"> import { useI18n } from "vue-i18n"; // A component with an <i18n> block resolves to local scope implicitly const { t } = useI18n({ useScope: "local" }); </script> <template> <button>{{ t("retry") }}</button> </template> <i18n lang="json"> { "en": { "retry": "Try again" }, "fr": { "retry": "Réessayer" } } </i18n> Custom blocks are good for reusable library components that must ship their own strings. For application code they scatter translations across hundreds of files that translators and tooling cannot easily find, and the vue-i18n docs note that type-safe resources do not cover custom blocks. Prefer central JSON files per locale (see our JSON translation files guide for structure), and keep custom blocks for the exceptions.
7. Type Your Message Keys
Treat the source locale as the schema. Declaring it globally gives you autocompletion and compile errors for misspelled keys in t():
// src/i18n/vue-i18n.d.ts import en from "../locales/en.json"; type MessageSchema = typeof en; declare module "vue-i18n" { export interface DefineLocaleMessage extends MessageSchema {} } The same pattern works for number and date presets through DefineNumberFormat and DefineDateTimeFormat. You can also pass the schema to createI18n<[MessageSchema], "en" | "fr">(...); TypeScript then reports a missing locale in the messages object. Both approaches check keys, not translation completeness, so pair them with a CI check (below) that compares every locale file against the source.
8. Nuxt: Let @nuxtjs/i18n Do the Heavy Lifting
In Nuxt 3 and Nuxt 4 projects, install the module instead of wiring vue-i18n by hand:
npx nuxi module add i18n // nuxt.config.ts export default defineNuxtConfig({ modules: ["@nuxtjs/i18n"], i18n: { baseUrl: "https://example.com", defaultLocale: "en", strategy: "prefix_except_default", locales: [ { code: "en", language: "en-US", name: "English", file: "en.json" }, { code: "fr", language: "fr-FR", name: "Français", file: "fr.json" }, { code: "de", language: "de-DE", name: "Deutsch", file: "de.json" }, ], detectBrowserLanguage: { useCookie: true, cookieKey: "i18n_redirected", redirectOn: "root", }, }, }); In v10, locale files live in i18n/locales/ at the project root, and every file is loaded lazily, so the old lazy option is gone. Runtime-only vue-i18n options (custom plural rules, formatters, number and date presets) go in i18n/i18n.config.ts:
// i18n/i18n.config.ts // formats.ts is the same file as in section 5, moved into i18n/ import { numberFormats, datetimeFormats } from "./formats"; export default defineI18nConfig(() => ({ fallbackLocale: "en", numberFormats, datetimeFormats, })); 

