Skip to content

Optional analytics, session recording and advertising stay off unless you accept. You can reject them and use Transglot. Change your choice anytime in Cookie preferences. Cookie Policy

Back to the blog
Developer platform

Vue Localization with Vue I18n: The Complete Guide (2026)

Vue localization with Vue I18n 11: setup, message syntax, Slavic plural rules, lazy loading, Vue Router, Nuxt, tests, lint, CI and checks for AI translation.

by transglot team
published November 23, 2026
26 min read

Documentation reviewed 23 November 2026.

Quick answer

Vue localization is done with Vue I18n. Install vue-i18n@11, create an instance with createI18n({ legacy: false, locale, fallbackLocale, messages }), register it with app.use(i18n), and read strings in components with const { t } = useI18n(). Messages live in one JSON file per language. Placeholders are written {name}, plurals are forms separated by a pipe, and dates and numbers go through d() and n() with named formats. Out of the box the plural rule in version 11 only fits languages shaped like English, so Russian, Polish or Arabic need a pluralRules function, which this guide supplies. On Nuxt, the @nuxtjs/i18n module adds localized routes, lazy loading and SEO tags on top of the same library.

What you will have at the end

The samples target Vue 3.5, Vue I18n 11.4, Vue Router 5, @intlify/unplugin-vue-i18n 11, @intlify/eslint-plugin-vue-i18n 4.5 and @nuxtjs/i18n 10.6, the current stable releases on npm at the review date. By the end you will have:

  • A Vue app that reads every string from JSON locale files through the Composition API.
  • Plurals that are correct in languages with three, four or six forms.
  • Dates, numbers and currency formatted per locale.
  • Locale files loaded on demand, a language switch that is remembered, and the locale in the URL.
  • A layout that works right to left, the lang attribute, and hreflang annotations for search engines.
  • Tests, lint rules and a CI job that fail on a missing or malformed translation.
  • A repeatable way to translate the JSON with AI and check what comes back.

It is for developers who own the Vue or Nuxt codebase.

A cream paper-pulp browser window on a stone plinth with a row of labelled paper cards slotted into its base, one card per language
One JSON file per language, one i18n instance, one t() call per string

Part 1: install Vue I18n and create the instance

Install

bashbash
npm install vue-i18n@11

npm may print a deprecation notice for version 11. The installation page calls that a mistake made while deprecating versions 9 and 10, which have reached end of life. Version 11 is maintained.

Write the first locale files

src/locales/en.jsonjson
{
"app": { "name": "Parcel Desk" },
"home": {
"greeting": "Welcome back, {name}",
"footer": "@:app.name is open every day"
},
"cart": { "items": "{n} item | {n} items" },
"legal": {
"accept": "I accept the {terms}.",
"terms": "terms of service"
}
}

Nested objects become dotted keys: home.greeting, cart.items.

Create the instance

src/i18n.jsjs
import { createI18n } from 'vue-i18n'
import en from './locales/en.json'
export const i18n = createI18n({
legacy: false,
locale: 'en',
fallbackLocale: 'en',
messages: { en }
})
src/main.jsjs
import { createApp } from 'vue'
import App from './App.vue'
import { i18n } from './i18n'
createApp(App).use(i18n).mount('#app')

app.use(i18n) has to run before mount. It enables useI18n, registers the <i18n-t>, <i18n-d> and <i18n-n> components, and injects $t, $d, $n and $i18n into templates.

Write locales as BCP 47 language tags: pt-BR, not pt_BR. Vue I18n passes the locale to the JavaScript Intl APIs and splits it at the hyphen to find a fallback. With pt_BR the fallback to pt does not happen, and date and number formatting throw a RangeError.

Use it in a component

vuevue
<script setup>
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
</script>
<template>
<h1>{{ t('home.greeting', { name: 'Ada' }) }}</h1>
</template>

Composition API or Legacy API

Composition APILegacy API
Turned on bylegacy: falseThe default when legacy is left out
In a componentconst { t, d, n, locale } = useI18n()this.$t, this.$i18n
Change the localei18n.global.locale.value = 'ru'i18n.global.locale = 'ru'
Plural rule optionpluralRulespluralizationRules
Silence warningsmissingWarn, fallbackWarnsilentTranslationWarn, silentFallbackWarn
Status in version 11RecommendedDeprecated, removed in version 12
createI18n still defaults to Legacy API mode in version 11, so legacy: false is not optional. Without it the instance logs a deprecation warning in development and i18n.global.locale is a plain string, not a ref, so the code in this guide does not apply. Tutorials that call $tc are older still: tc and $tc were removed in version 11, and plurals go through t. The v-t directive is deprecated in version 11 and removed in version 12.
Watch out

Part 2: where the messages live

OptionHowFits
JSON file per localesrc/locales/en.json, imported or loaded on demandMost apps. Translators and localization tools read it, and TypeScript can derive a schema from it
YAML or JSON5 file per localeSame layout, compiled by @intlify/unplugin-vue-i18nTeams that want comments in the source file. The plugin reads simple YAML only: no anchors, aliases, tags or multi-document files
<i18n> block in a componentMessages inside the .vue file, JSON by default, lang="yaml" for YAMLStrings used by one component. They are local scope, need the bundler plugin, and typed messages do not cover them

An <i18n> block looks like this:

vuevue
<i18n lang="yaml">
en:
hello: Hello
ru:
hello: Привет
</i18n>

A component with an <i18n> block gets a local scope from useI18n(). Without a block it gets the global scope. Strings inside source files are harder to send to a translator, so this guide keeps everything in JSON files.


Part 3: message format syntax

FeatureMessageCallResult
Named interpolationWelcome back, {name}t('home.greeting', { name: 'Ada' })Welcome back, Ada
List interpolation{0} of {1}t('page', [2, 10])2 of 10
Literal interpolation{account}{'@'}{domain}t('mail', { account: 'help', domain: 'example.com' })help@example.com
Linked message@:app.name is open every dayt('home.footer')Parcel Desk is open every day
Linked with modifierPlease provide @.lower:form.addresst('form.error')The linked text in lower case

Five characters are special to the message compiler: {, }, @, $ and the pipe. To print one, wrap it in literal interpolation, {'@'}, or since version 11.3 escape it with a backslash, which in JSON is written \\@.

The built-in modifiers for linked messages are upper, lower and capitalize.

A linked key ends at a space, a tab, a line break or one of {, @, the pipe, ( and ). A comma or full stop is read as part of the key. @:app.name, welcome looks up a key named app.name, and prints the key. Write @:{'app.name'}, welcome.
Watch out

HTML in messages

A message can contain HTML and be rendered with v-html, which the documentation marks as a cross-site scripting risk. Vue I18n warns in development when a message contains HTML, and the bundler plugin's strictMessage option, on by default, stops the build when a compiled locale file contains a tag. If HTML must stay, the escapeParameter option escapes the values passed into such messages. The better answer is <i18n-t> in Part 5.


Part 4: pluralization, including Slavic languages

The pipe syntax

A plural message is a list of forms separated by a pipe. You pass the number as the second argument:

jsjs
t('cart.items', 1) // "1 item"
t('cart.items', 5) // "5 items"

Inside the message, {n} and {count} are filled with that number automatically.

What the default rule does

With no custom rule, version 11 chooses a form like this, which you can read in the pluralDefault function of the source:

  • Two forms: the first for exactly 1, the second for everything else.
  • Three or more forms: the first for 0, the second for 1, the third for every other number.

That is English. In a test for this guide, an unconfigured instance given a Russian message printed "21 товаров" where Russian needs "21 товар". No warning appears, because every form index exists.

The rule in the documentation

The Vue I18n pluralization page gives a simplified rule for Slavic languages. It expects four forms in the order zero, one, few, many:

the documented Slavic rule, Composition API option namejs
function slavicRule(choice, choicesLength) {
if (choice === 0) return 0
const teen = choice > 10 && choice < 20
const endsWithOne = choice % 10 === 1
if (!teen && endsWithOne) return 1
if (!teen && choice % 10 >= 2 && choice % 10 <= 4) return 2
return choicesLength < 4 ? 2 : 3
}
const i18n = createI18n({
legacy: false,
locale: 'ru',
pluralRules: { ru: slavicRule },
messages: {
ru: { car: '0 машин | {n} машина | {n} машины | {n} машин' }
}
})

With it, 2 prints "2 машины", 12 prints "12 машин" and 21 prints "21 машина".

One rule for every language

A function per language does not scale, and the browser already knows the rules. Intl.PluralRules returns the Unicode CLDR category for a number, and resolvedOptions().pluralCategories lists the categories a locale uses. This factory turns that into a Vue I18n rule:

src/plural.jsjs
const ORDER = ['zero', 'one', 'two', 'few', 'many', 'other']
export function cldrRule(locale) {
const rules = new Intl.PluralRules(locale)
const used = rules.resolvedOptions().pluralCategories
const categories = ORDER.filter((c) => used.includes(c))
return (choice, choicesLength) => {
const index = categories.indexOf(rules.select(Math.abs(choice)))
return Math.min(index, choicesLength - 1)
}
}

Register it for every locale, including English, so one convention holds across all files:

jsjs
const SUPPORTED = ['en', 'ru', 'ar']
export const i18n = createI18n({
legacy: false,
locale: 'en',
fallbackLocale: 'en',
messages: { en },
pluralRules: Object.fromEntries(SUPPORTED.map((l) => [l, cldrRule(l)]))
})

The convention: each message carries one form per CLDR category of its language, in the order zero, one, two, few, many, other.

LanguageCategories, in orderForms
Japaneseother1
English, Germanone, other2
Frenchone, many, other3
Russian, Polish, Ukrainianone, few, many, other4
Arabiczero, one, two, few, many, other6
src/locales/ru.jsonjson
{
"cart": { "items": "{n} товар | {n} товара | {n} товаров | {n} товара" }
}

Run against Vue I18n 11.4, that message printed "1 товар", "2 товара", "5 товаров", "11 товаров" and "21 товар". The fourth form, other, is the one Russian uses for fractions such as 1.5.

Two groups of cream paper-pulp tiles on a stone plinth: two tiles on the left, four tiles on the right, with a paper strip threaded between them like a pipe
English fills two forms between the pipes. Russian fills four.
Put the whole sentence in every form. {n} | item | items glued to other text in the template forces English word order on every language.
Rule

On the development branch for version 12, the source picks the form with Intl.PluralRules when no custom rule is set. Version 11 does not.


Part 5: markup inside a sentence with `<i18n-t>`

"I accept the terms of service", with the last three words as a link, is one sentence. Two keys break in languages where the link sits in the middle, and an <a> tag in the message means v-html. With the translation component, the message holds a placeholder and a named slot fills it.

vuevue
<i18n-t keypath="legal.accept" tag="label" scope="global">
<template #terms>
<a href="/terms">{{ t('legal.terms') }}</a>
</template>
</i18n-t>

With the Russian file this rendered <label>Я принимаю <a href="/terms">условия обслуживания</a>.</label> in the test for this guide. The translator moves {terms} wherever the grammar needs it.

Details from the documentation:

  • keypath is the message key. tag is the wrapper element, and without it the component renders a fragment.
  • plural takes a number, so a plural message can have its {n} rendered through a slot: <i18n-t keypath="cart.items" :plural="count"> with a #n slot.
  • Slot props are not supported.
  • Without a local scope on the parent, the component logs "Not found parent scope. use the global scope." in development. scope="global" removes the warning.

Part 6: dates and numbers

Define named formats per locale. The options are those of Intl.DateTimeFormat and Intl.NumberFormat:

jsjs
const datetimeFormats = {
en: { short: { year: 'numeric', month: 'short', day: 'numeric' } },
ru: { short: { year: 'numeric', month: 'short', day: 'numeric' } }
}
const numberFormats = {
en: { currency: { style: 'currency', currency: 'EUR' } },
ru: { currency: { style: 'currency', currency: 'EUR' } }
}
export const i18n = createI18n({
legacy: false,
locale: 'en',
messages: { en },
datetimeFormats,
numberFormats
})
vuevue
<script setup>
import { useI18n } from 'vue-i18n'
const { d, n } = useI18n()
</script>
<template>
<p>{{ d(new Date(), 'short') }}</p>
<p>{{ n(1234.5, 'currency') }}</p>
</template>

For 23 November 2026 and 1234.5 this printed "Nov 23, 2026" and "€1,234.50" in English, and "23 нояб. 2026 г." and "1 234,50 €" in Russian. A third argument overrides the locale for one call: n(1234.5, 'currency', 'en').

The option is spelled datetimeFormats, with a lower case t, since version 9. When part of a value needs its own styling, such as smaller decimals in a price, the <i18n-n> and <i18n-d> components expose each part as a slot.

A number format fixes the currency. currency: 'EUR' under the ru locale prints euros with Russian separators. It does not convert the amount, and it should not differ per locale unless your prices do.
Watch out

Part 7: fallback and missing keys

fallbackLocale names the language used when the active one lacks a key. It accepts a string, an array, or a map such as { 'de-CH': ['fr', 'it'], default: ['en'] }. A locale with a region also falls back implicitly: de-DE tries de before the fallback locale.

When a key exists in no locale, t returns the key itself. In development Vue I18n logs two warnings, one for the missing key and one for the fallback. Neither is logged in production.

The options that control this in Composition API mode:

OptionEffect
missingWarn: falseSilences "Not found key" for every locale. Also accepts a regular expression
fallbackWarn: falseSilences "Fall back to translate"
missing: (locale, key) => {}Called for each locale that lacks the key, in fallback order
fallbackFormat: trueInterpolates the key itself when no translation exists, for apps that use sentences as keys

To hear only about keys that no locale has, turn both warnings off and report from the handler when it reaches the last fallback:

jsjs
export const i18n = createI18n({
legacy: false,
locale: 'ru',
fallbackLocale: 'en',
missingWarn: false,
fallbackWarn: false,
missing: (locale, key) => {
if (locale === 'en') reportMissingKey(key) // your logger
},
messages: { en }
})

Part 8: lazy loading, switching and the URL

Load a locale when it is needed

Bundling every language into the first download is wasted bytes for most visitors. Import the file on demand and hand it to setLocaleMessage:

src/i18n.js, continuedjs
import { nextTick } from 'vue'
export const SUPPORTED = ['en', 'ru', 'ar']
const RTL = ['ar', 'he', 'fa', 'ur']
export async function setLocale(locale) {
if (!i18n.global.availableLocales.includes(locale)) {
const messages = await import(`./locales/${locale}.json`)
i18n.global.setLocaleMessage(locale, messages.default)
}
i18n.global.locale.value = locale
document.documentElement.lang = locale
document.documentElement.dir = RTL.includes(locale) ? 'rtl' : 'ltr'
localStorage.setItem('locale', locale)
return nextTick()
}

i18n.global.locale is a ref in Composition API mode, so the assignment goes through .value, and every component on the global scope re-renders. The documentation's example sets lang at the same point and suggests setting an Accept-Language header for your HTTP client there too.

Pick the starting locale

jsjs
export function startingLocale() {
const saved = localStorage.getItem('locale')
const browser = navigator.language.split('-')[0]
return [saved, browser].find((l) => SUPPORTED.includes(l)) ?? 'en'
}

A saved choice wins over the browser language.

Put the locale in the URL

A locale kept only in localStorage cannot be linked to or indexed. Make it the first path segment and let a navigation guard load it:

src/router.js, Vue Router 5js
import { createRouter, createWebHistory } from 'vue-router'
import { SUPPORTED, setLocale, startingLocale } from './i18n'
const router = createRouter({
history: createWebHistory(),
routes: [
{
path: '/:locale',
children: [
{ path: '', name: 'home', component: () => import('./pages/Home.vue') },
{ path: 'orders', name: 'orders', component: () => import('./pages/Orders.vue') }
]
},
{ path: '/:pathMatch(.*)*', redirect: () => `/${startingLocale()}` }
]
})
router.beforeEach(async (to) => {
const locale = to.params.locale
if (!SUPPORTED.includes(locale)) return `/${startingLocale()}`
await setLocale(locale)
})
export default router

The guard returns a path to redirect and nothing to continue. The Vue I18n lazy loading page still shows the next() callback, which the Vue Router documentation says logs a deprecation warning since version 5.0.3.

Links inside the app now carry the locale: { name: 'orders', params: { locale: locale.value } }. A language switch is a router.push to the same route with another locale parameter.


Part 9: the build plugin and TypeScript

`@intlify/unplugin-vue-i18n`

bashbash
npm install -D @intlify/unplugin-vue-i18n
vite.config.jsjs
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import vue from '@vitejs/plugin-vue'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
vue(),
VueI18nPlugin({
include: resolve(dirname(fileURLToPath(import.meta.url)), './src/locales/**')
})
]
})

What the plugin does, according to its README:

  • Compiles messages at build time. Files matched by include (JSON, JSON5, YAML, JS, TS) are compiled ahead of time, so a syntax error fails the build, not the page.
  • Selects the smaller runtime. In a production build it aliases Vue I18n to the runtime-only file, vue-i18n.runtime.esm-bundler.js.
  • Enables <i18n> blocks, with json, json5, yaml or yml in the lang attribute.
  • Rejects HTML in messages through strictMessage, on by default.
  • Offers one import for everything: import messages from '@intlify/unplugin-vue-i18n/messages' merges every file under include. That is the opposite of lazy loading, so it suits small apps.

Since version 10, Vue I18n also compiles messages just in time by default, so messages fetched from an API at runtime work, including under a content security policy that forbids eval.

Typed messages

Derive a schema from the source file and pass it to createI18n:

tsts
import { createI18n } from 'vue-i18n'
import en from './locales/en.json'
import ru from './locales/ru.json'
type MessageSchema = typeof en
export const i18n = createI18n<[MessageSchema], 'en' | 'ru'>({
legacy: false,
locale: 'en',
messages: { en, ru }
})

TypeScript now reports a locale missing from messages and a locale file that lacks a key the source has. Both errors were reproduced with tsc for this guide. The documentation lists two limits: type safety covers JSON resources only, and not <i18n> blocks.

Testing showed two more. Every locale in the type parameter must be present in messages, which conflicts with lazy loading. And a misspelled key passed to t() compiled without an error: the schema gives key completion, not a hard failure. The lint rule in Part 12 covers that gap.


Part 10: right to left and SEO

Right to left

setLocale above sets dir="rtl" on <html> for Arabic, Hebrew, Persian and Urdu. CSS written with physical sides does not follow. Use logical properties, which are defined relative to the writing direction:

PhysicalLogical
margin-leftmargin-inline-start
padding-rightpadding-inline-end
left: 0inset-inline-start: 0

Icons that point somewhere, such as back arrows, need mirroring by hand. Check one right to left language early.

`lang` and `hreflang`

Google's documentation sets three rules for hreflang: each language version lists itself and every other version, the URLs are fully qualified, and an x-default entry names the page for users who match no language. The annotations can live in <link> tags, HTTP headers or the sitemap, which Google treats as equivalent.

The same page says Google does not use the lang attribute to detect a page's language. Set it anyway, for screen readers.

For a client-rendered Vue app, give each locale its own URL (Part 8) and declare the alternates in the sitemap, which does not depend on JavaScript running. For server-rendered pages, Nuxt generates the tags.
In short

Part 11: Nuxt with `@nuxtjs/i18n`

The Nuxt module configures Vue I18n 11 for you and adds routing on top.

bashbash
npx nuxi@latest module add @nuxtjs/i18n
nuxt.config.ts, @nuxtjs/i18n 10ts
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: 'ru', language: 'ru-RU', name: 'Русский', file: 'ru.json' },
{ code: 'ar', language: 'ar-EG', name: 'العربية', dir: 'rtl', file: 'ar.json' }
],
detectBrowserLanguage: {
useCookie: true,
cookieKey: 'i18n_redirected',
redirectOn: 'root'
}
}
})

Locale files are read from i18n/locales by default.

Routing strategies

StrategyURLsFits
prefix_except_default (default)/about, /ru/aboutSites that started in one language and want its URLs unchanged
prefix/en/about, /ru/aboutSites that want every language treated the same
prefix_and_defaultBoth /about and /en/about for the default languageMigrations. The canonical link points to the unprefixed page
no_prefix/about for every languageApps behind a login. The locale comes from the cookie and the browser, and there is nothing for a crawler to tell apart

What the module handles

  • Lazy loading. In version 10 every locale file is lazy loaded. The lazy option from earlier versions is gone.
  • Links. useLocalePath() returns a function that resolves a route for the current locale: localePath('about'). useSwitchLocalePath() returns the current page in another language, for the language switch. setLocale(code) from useI18n() switches and updates the cookie.
  • Detection. detectBrowserLanguage redirects by browser language and remembers the choice in a cookie. redirectOn: 'root' is the default and the documented recommendation for SEO, because only the root path redirects and crawlers can reach every localized page.
  • SEO tags. useLocaleHead() returns the lang and dir attributes for <html>, the hreflang alternate links, Open Graph locale tags and a canonical link. It needs language on every locale and baseUrl set, as above. Wire it once:
app.vuevue
<script setup>
useHead(useLocaleHead())
</script>
<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>
  • Vue I18n options. Options that are functions, such as pluralRules, cannot go in nuxt.config. They go in i18n/i18n.config.ts:
i18n/i18n.config.tsts
// cldrRule is the factory from Part 4, defined above in this file.
export default defineI18nConfig(() => ({
fallbackLocale: 'en',
pluralRules: { en: cldrRule('en'), ru: cldrRule('ru'), ar: cldrRule('ar') }
}))

This file is loaded at runtime on each request, the documentation notes, so keep it small.


Part 12: tests, lint and CI

Test a component in a locale

Vue Test Utils installs plugins through global.plugins. Build a fresh i18n instance per test so one test cannot leak its locale into the next:

tests/CartSummary.test.js, Vitest with the happy-dom environmentjs
import { mount } from '@vue/test-utils'
import { createI18n } from 'vue-i18n'
import { describe, expect, it } from 'vitest'
import CartSummary from '../src/CartSummary.vue'
import en from '../src/locales/en.json'
import ru from '../src/locales/ru.json'
import { cldrRule } from '../src/plural.js'
function mountWithLocale(component, locale, props) {
const i18n = createI18n({
legacy: false,
locale,
fallbackLocale: 'en',
messages: { en, ru },
pluralRules: { en: cldrRule('en'), ru: cldrRule('ru') }
})
return mount(component, { props, global: { plugins: [i18n] } })
}
describe('CartSummary in Russian', () => {
it.each([
[1, '1 товар'],
[3, '3 товара'],
[5, '5 товаров'],
[21, '21 товар']
])('uses the right plural form for %i', (count, text) => {
const wrapper = mountWithLocale(CartSummary, 'ru', { count })
expect(wrapper.find('.count').text()).toBe(text)
})
})

Test the boundaries of the language with the most forms you ship: for Russian and Polish, 1, 3, 5 and 21. The Vue Test Utils API page also shows config.global.mocks = { $t: (text) => text }. That mock hides plural and placeholder bugs, so keep it away from components where those matter.

Lint for missing and unused keys

bashbash
npm install --save-dev eslint @intlify/eslint-plugin-vue-i18n
eslint.config.jsjs
import vueI18n from '@intlify/eslint-plugin-vue-i18n'
export default [
...vueI18n.configs.recommended,
{
rules: {
'@intlify/vue-i18n/no-unused-keys': ['error', { extensions: ['.js', '.vue'] }],
'@intlify/vue-i18n/no-missing-keys-in-other-locales': 'error',
'@intlify/vue-i18n/no-dynamic-keys': 'error',
'@intlify/vue-i18n/valid-plural-forms': [
'error',
{ pluralFormCounts: { en: [2], ru: [4], ar: [6] } }
]
},
settings: {
'vue-i18n': {
localeDir: './src/locales/*.json',
messageSyntaxVersion: '^11.0.0'
}
}
}
]
RuleCatchesIn recommended
no-missing-keyst('home.greting'): a key used in code that no locale file hasYes
no-raw-textHardcoded text in a templateYes
no-v-htmlA translation rendered with v-htmlYes
no-html-messagesHTML inside a locale messageYes
valid-message-syntaxA message the compiler cannot parseYes
no-unused-keysKeys in the files that no code usesNo
no-missing-keys-in-other-localesA key present in one locale file and absent from anotherNo
no-dynamic-keyst(variable), which the other rules cannot followNo
valid-plural-formsThe wrong number of plural forms for a locale, since plugin version 4.2No

Run ESLint over the locale files too, for example eslint "src/**/*.{js,vue,json}". The plugin's documentation states that TypeScript locale files are not supported.

CI

.github/workflows/i18n.ymlyaml
name: i18n
on: [pull_request]
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx eslint "src/**/*.{js,vue,json}"
- run: node scripts/check-locales.mjs
- run: npx vitest run
- run: npm run build

With the bundler plugin, a malformed message stops the build step. If your team translates after merge, move the missing-key checks to the release workflow so feature branches are not blocked on translators. Localization as code covers that trade.


Part 13: translating Vue I18n JSON with AI, and checking it

A model translates interface text well enough to draft every language in one run. Vue I18n files are where the drafts break, because the values mix prose with syntax that looks like punctuation.

What breaksExampleEffect
A placeholder is translated{name} becomes {nombre} or {имя}A Latin name compiles and the value is silently dropped. A non-Latin name is a compile error
The English plural shape is copiedTwo forms in a Russian or Arabic fileValid message, wrong word for most numbers
The plural is flattenedOne form where the source had twoEvery number prints the same form
A pipe is added to plain text"Orders, open or closed" rewritten with a pipeThe message becomes a plural and prints only its first half
A linked key is translated@:app.name becomes @:приложение.имяThe key is printed as text
Punctuation moves next to a linked key@:app.name,A different key is looked up
Literal interpolation is unwrapped{'@'} becomes @Compile error: "Invalid linked format"
A tag is added or changed<b> around a wordThe build fails under strictMessage, or a tag is lost
A key is translated"greeting" becomes "приветствие"The original key is missing

The pipe is what separates Vue I18n from other JSON formats. To a model it is punctuation, and nothing in the file says that Russian needs four forms. How to translate JSON i18n files with AI covers the general case. For this format, a script can check all of it:

scripts/check-locales.mjs, Node.js 22, no dependenciesjs
import { readdirSync, readFileSync } from 'node:fs'
import { basename, join } from 'node:path'
const dir = 'src/locales'
const source = 'en'
const flatten = (node, prefix = '', out = {}) => {
for (const [key, value] of Object.entries(node)) {
const path = prefix ? `${prefix}.${key}` : key
if (typeof value === 'string') out[path] = value
else flatten(value, path, out)
}
return out
}
const read = (locale) =>
flatten(JSON.parse(readFileSync(join(dir, `${locale}.json`), 'utf8')))
// Split on pipes that are not escaped and not inside {'...'}.
const forms = (m) => m.replace(/\{'[^']*'\}/g, '').split(/(?<!\\)\|/)
const sorted = (list) => [...new Set(list)].sort().join(' ')
const named = (m) =>
sorted(m.replace(/\{'[^']*'\}/g, '').match(/\{[^{}]*\}/g) ?? [])
const literal = (m) => sorted(m.match(/\{'[^']*'\}/g) ?? [])
const linked = (m) =>
sorted(m.match(/@(?:\.\w+)?:(?:\{'[^']*'\}|[^\s{}@|()]+)/g) ?? [])
const tags = (m) => sorted(m.match(/<\/?[a-zA-Z][^>]*>/g) ?? [])
const formCount = (locale) =>
new Intl.PluralRules(locale).resolvedOptions().pluralCategories.length
const base = read(source)
const problems = []
for (const file of readdirSync(dir).filter((f) => f.endsWith('.json'))) {
const locale = basename(file, '.json')
const target = read(locale)
const report = (key, text) => problems.push(`${file}: "${key}" ${text}`)
for (const key of Object.keys(target)) {
if (!(key in base)) report(key, 'is not a key in the source file')
}
for (const [key, text] of Object.entries(base)) {
const value = target[key]
if (value === undefined) {
report(key, 'is missing')
continue
}
if (named(text) !== named(value)) report(key, 'placeholders differ')
if (literal(text) !== literal(value)) report(key, 'literal interpolation differs')
if (linked(text) !== linked(value)) report(key, 'linked message differs')
if (tags(text) !== tags(value)) report(key, 'HTML tags differ')
const isPlural = forms(text).length > 1
const count = forms(value).length
if (!isPlural && count > 1) {
report(key, 'has a pipe but the source is not a plural')
}
if (isPlural && count !== formCount(locale)) {
report(key, `has ${count} plural forms, ${locale} needs ${formCount(locale)}`)
}
}
}
problems.forEach((p) => console.error(p))
process.exit(problems.length ? 1 : 0)

It assumes the convention from Part 4. Run against a deliberately broken Polish file, it reported the translated placeholder, the unwrapped {'@'}, the changed linked key, the stray pipe, the two-form plural where Polish needs four, the added <b> tag, the invented key and the missing key.

It cannot see meaning. A fluent sentence that says the wrong thing passes every check here. Automated localization QA lists what can be checked without a person and what cannot.

When you prompt a model yourself, send it values and write the answers back by key. Tell it the number of plural forms the target language needs and their order. A model that never sees the keys cannot translate them.
Rule
A cream paper-pulp gate with narrow vertical slots on a stone plinth, paper cards passing through and one card with a torn edge set aside
Placeholders, linked keys, tags and plural form counts are checked before a file is merged

Doing this with Transglot

Transglot is a continuous localization platform. Glossa, its translation engine, translates the strings that changed, and four quality checks run on every string before it is written: placeholders, plural forms, glossary terms and length. A string that still fails the placeholder, plural or glossary check after one repair is refused and reported, not written.

Vue I18n locale files are read and written as the format json_nested. From the project root, with Node.js 22 or later:

bashbash
npx transglot@latest init --targets ru,ar

init finds the locale files, works out the source language, signs in through the browser, runs the first translation and writes transglot.json:

transglot.jsonjson
{
"url": "https://api.transglot.ai",
"sources": [
{ "path": "src/locales/{locale}.json", "format": "json_nested", "locales": ["en"] }
],
"pull": [
{ "path": "src/locales/{locale}.json", "format": "json_nested" }
]
}

After that, transglot push --wait uploads changed strings and waits for the translation, and transglot pull writes the target files. The configuration reference explains each field, and the GitHub Action runs the same round trip on every push to main.

What the documentation says, and does not say, for a Vue project:

  • Placeholders and tags are checked. The formats page lists single braces such as {name} and {0}, and HTML tags, among the syntaxes the placeholder check recognizes. Values are written back exactly as they are.
  • A pipe plural is an ordinary string. The plural check is documented for plural keys and ICU plural messages. The documentation does not mention the Vue I18n pipe syntax, so do not assume the number of forms is checked. Keep scripts/check-locales.mjs and the valid-plural-forms rule in CI.
  • Linked messages are not in the documented list. @:key is not among the recognized placeholder syntaxes. The script above checks it.
  • Untranslated keys are left out of a pulled file, so fallbackLocale and the missing-key lint rule keep doing their jobs.
  • Use JSON, not YAML. The yaml format expects the Rails layout, with one root key naming the locale.
  • The Vue runtime package is not a Vue I18n plugin. @transglot/vue loads published translations from the Transglot CDN through its own useTranslations() and t, and does not server-render. An app already built on Vue I18n fits the file workflow above.
  • The command line starts on a paid plan. The Free plan works in the browser console. The CLI, the GitHub Action and the API start on Starter, at $19 a month for 300,000 translated words. Transglot is not self-hostable. See pricing.

Other platforms read nested JSON too. Test any of them on a four-form plural and a linked message first.


Common mistakes

  • Leaving out legacy: false. Version 11 still defaults to the deprecated Legacy API, where the global locale is not a ref.
  • Following a $tc tutorial. It was removed in version 11. Plurals go through t.
  • Trusting the default plural rule. It is English. Russian, Polish, Ukrainian and Arabic need pluralRules.
  • Underscore locales. pt_BR breaks the fallback and throws in d() and n(). Write pt-BR.
  • Punctuation after a linked key. @:app.name, looks up the wrong key.
  • A raw @ or pipe in a message. Use {'@'} and {'|'}.
  • HTML in messages with v-html. Use <i18n-t>.
  • Putting pluralRules in nuxt.config. Functions go in i18n/i18n.config.ts.

Checklist

texttext
[ ] vue-i18n@11 installed, createI18n called with legacy: false
[ ] One JSON file per locale, locales written as BCP 47 tags
[ ] Every user-facing string read through t()
[ ] pluralRules registered for every locale, one form per CLDR category
[ ] Whole sentences in every plural form
[ ] Links and markup inside sentences use <i18n-t>
[ ] datetimeFormats and numberFormats defined, d() and n() used
[ ] fallbackLocale set, missing handler reports keys no locale has
[ ] Locale files loaded on demand with setLocaleMessage
[ ] Chosen locale saved, and present in the URL
[ ] lang and dir set on <html>, CSS uses logical properties
[ ] hreflang alternates declared with full URLs and x-default
[ ] @intlify/unplugin-vue-i18n compiles the locale files
[ ] Component tests mount a real i18n instance and test plural boundaries
[ ] ESLint plugin runs on .vue, .js and .json files
[ ] check-locales.mjs runs in CI
[ ] One right to left language and one four-form language in the first batch

Frequently asked questions

How do I add i18n to a Vue 3 app?

Install vue-i18n@11, call createI18n({ legacy: false, locale: 'en', fallbackLocale: 'en', messages }), and register it with app.use(i18n) before mounting. In components, call const { t } = useI18n() and use t('key') in the template.

What is the difference between the Composition API and the Legacy API in Vue I18n?

Composition API mode is turned on with legacy: false and uses useI18n() inside setup. The Legacy API is the version 8 style built on this.$t. It is deprecated in version 11 and removed in version 12.

How does pluralization work in Vue I18n?

A plural message lists its forms separated by a pipe, such as {n} item | {n} items, and you call t('cart.items', count). The built-in rule handles two forms, or three with a form for zero. Other languages need a function in pluralRules that returns the index of the form for a number.

How do I pluralize Russian or Polish in Vue I18n?

Pass a custom rule in pluralRules for that locale and write four forms in the message. The rule can be written by hand, as in the Vue I18n documentation, or built on Intl.PluralRules, which returns one, few, many or other for any number.

How do I lazy load translations in Vue I18n?

Import the locale file with a dynamic import(), pass it to i18n.global.setLocaleMessage(locale, messages.default), then set i18n.global.locale.value. In Nuxt with @nuxtjs/i18n version 10, locale files are lazy loaded without configuration.

How do I change the language at runtime in Vue?

Set the global locale: i18n.global.locale.value = 'ru', or the locale ref returned by useI18n({ useScope: 'global' }). Components re-render in the new language. Save the choice, and update lang and dir on <html> at the same time.

What is the difference between vue-i18n and @nuxtjs/i18n?

vue-i18n is the library that stores messages and translates. @nuxtjs/i18n is a Nuxt module that configures Vue I18n 11 and adds localized routes, browser language detection, lazy loaded locale files and SEO head tags.

Can I use AI to translate Vue I18n JSON files?

Yes, with checks. A model can translate {name} placeholders and @:linked keys, add or remove pipes, and copy the two English plural forms into a language that needs four. Compare all of these against the source file before merging.

How this guide was checked

  • Installation, createI18n, the API modes, message syntax, pluralization, component interpolation, datetime and number formatting, fallback, lazy loading, TypeScript support and the version 10 and 11 breaking changes follow the Vue I18n documentation for version 11, linked under Sources.
  • The default plural rule, and the statement about the version 12 development branch, were read in the core-base source of the Vue I18n repository and in the published 11.4 package.
  • The bundler plugin, the lint rules, navigation guards and global.plugins follow the @intlify/unplugin-vue-i18n README and the documentation of @intlify/eslint-plugin-vue-i18n, Vue Router and Vue Test Utils. The Nuxt part follows the @nuxtjs/i18n version 10 documentation.
  • Run for this guide with Node.js 22, Vue 3.5 and Vue I18n 11.4: instance setup, interpolation, linked messages, both plural rules, the unconfigured Russian case, date and number output, the missing handler, the <i18n-t> samples, the component test under Vitest, the two TypeScript errors, the failures listed in Part 13, and scripts/check-locales.mjs against a correct Russian file and a broken Polish file. The router sample was run with Vue Router 5.5 in Node.js, using memory history and stubbed localStorage, navigator and document.
  • Not run: the Vite plugin configuration, the ESLint configuration, the Nuxt samples and the CI workflow were written to the documentation and not executed. Nothing was run in a real browser.
  • The hreflang rules are from Google's linked page. The plural categories are those Intl.PluralRules returned in Node.js 22.
  • No translation platform was benchmarked. Transglot statements follow the Transglot documentation, including the limits listed in that section.

Sources

colophon

Who wrote this, and what to read next

wrote this

transglot team

The byline on this post has no profile yet. Author profiles are managed alongside the posts themselves.

Engineering
keep reading

How to Translate JSON i18n Files with AI

Three ways to translate a JSON locale file with AI, what breaks when you paste it into a chatbot, and the checks that keep keys, placeholders and plurals intact.

November 23, 2026
8 min read
keep reading

Automated localization QA with Transglot

Catch broken placeholders, incomplete plurals and terminology conflicts. Learn what automated QA proves, where human review matters and how to validate a release.

March 31, 2026
6 min read
keep reading

Localization as code: automate translations in CI/CD

Connect localization to CI/CD with scoped tokens, explicit waiting, reviewed translation snapshots and a recovery path for failed or partial runs.

February 24, 2026
7 min read
works with what you already run

41 connectors, already built.

the pipeline this post describes

Try it on your own strings. Free, no card.

Free plan: 100,000 words to start (25,000 at sign-up, 75,000 after a phone check), then 10,000 a month, 15 locales including your source, 3 seats.