How to localize a Vue app
vue-i18n is the standard internationalization plugin for Vue 3. You define messages as JSON, register the plugin, and read strings with $t in templates or t() in the Composition API. Here’s the setup plus how to auto-translate and sync.
i18n in Vue
The usual setup uses vue-i18n. vue-i18n loads a messages object keyed by locale, resolves keys (nested with dot notation) at runtime, and re-renders on locale change. Named interpolation uses single-brace {name} syntax.
import { createI18n } from 'vue-i18n'
import en from './locales/en.json'
import de from './locales/de.json'
export const i18n = createI18n({
legacy: false,
locale: 'en',
fallbackLocale: 'en',
messages: { en, de },
})<script setup>
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
</script>
<template>
<h1>{{ t('greeting', { name: 'Sam' }) }}</h1>
</template>
<!-- locales/en.json → { "greeting": "Hello, {name}!" } -->Translate it with nlit
- 1Add your source-language strings to nlit as keys (import your existing files, or start fresh).
- 2Run AI auto-translate into every target language — the credit cost is shown before each run, and your glossary keeps brand terms intact.
- 3Review and approve, then pull the files into your repo with the CLI.
# .nlit.yaml
format: json-nested
output_dir: src/locales
platform: web
languages:
- de
- fr
- jasrc/locales/
de/
messages.json
fr/
messages.json
ja/
messages.jsonFormat for Vue: json-nested. See the CLI docs for every format and flag.
Things to watch for
- vue-i18n uses single-brace {name} interpolation — configure your nlit keys to match.
- Use vue-i18n’s pluralization with nlit’s plural keys so each language gets correct CLDR forms.
- Group messages into modules so the project scales beyond one giant locale file.
FAQ
What i18n library should I use with Vue 3?
vue-i18n is the official, most widely used option and works directly with the JSON nlit exports.
How do I auto-translate a Vue app?
Add your source strings to nlit, run AI auto-translate (with the credit cost shown upfront), review, then pull the JSON into src/locales with the CLI.
Does nlit handle Vue’s {name} interpolation?
Yes. Define keys with single-brace placeholders and nlit preserves them through AI translation and export.
Ship Vue in every language
Auto-translate your strings and pull them into your build. Free to start, no card.