Translate Vue Single-File Components
Simplify Vue.js localization with Lingo.dev's direct support for Vue I18n single-file components - no separate translation files needed.
Quick Setup
Create an i18n.json
configuration file in your project root:
{
"version": 1,
"locale": {
"source": "en",
"targets": ["es", "fr", "de"]
},
"buckets": {
"vue-json": {
"include": ["src/**/*.vue"]
}
}
}
This configuration:
- Sets English as your source language
- Targets Spanish, French, and German translations
- Processes all
.vue
files in yoursrc
directory and subdirectories
Find Supported Languages
Discover all available language options:
# View source language options
npx lingo.dev@latest show locale sources
# View target language options
npx lingo.dev@latest show locale targets
One Command Translation
Translate all your Vue components with a single command:
npx lingo.dev@latest i18n
This automatically:
- Scans your Vue components for
<i18n>
blocks - Identifies new or modified content
- Translates only what's changed
- Updates translations directly in your components
How It Works with Vue Components
Lingo.dev works directly with Vue's standard i18n structure:
<template>
<div>
<h1>{{ $t("welcome") }}</h1>
<p>{{ $t("description") }}</p>
</div>
</template>
<i18n>
{
"en": {
"welcome": "Welcome",
"description": "This is a Vue component"
}
}
</i18n>
After translation, your component will contain all target languages:
<i18n>
{
"en": {
"welcome": "Welcome",
"description": "This is a Vue component"
},
"es": {
"welcome": "Bienvenido",
"description": "Este es un componente Vue"
},
"fr": {
"welcome": "Bienvenue",
"description": "Ceci est un composant Vue"
}
}
</i18n>
Advanced Configuration Options
Exclude Specific Components
Keep certain components untranslated:
"vue-json": {
"include": ["src/**/*.vue"],
"exclude": ["src/components/NoTranslate.vue"]
}
Hybrid Translation Approach
Combine component-based and file-based translations:
"buckets": {
"vue-json": {
"include": ["src/**/*.vue"]
},
"json": {
"include": ["src/locales/[locale].json"]
}
}
This setup allows you to:
- Keep component-specific translations within components
- Store global translations in separate JSON files
Why Vue Developers Choose This Approach
- Component Cohesion: Keeps translations with the components that use them
- Zero Extraction: No need to extract strings to separate files
- Context-Aware: AI understands component context for better translations
- Incremental Updates: Only translates what's changed, saving time and resources
- Standard Compatibility: Works with Vue I18n's recommended patterns
By integrating Lingo.dev into your Vue development workflow, you get powerful AI-driven translations while maintaining the component-based architecture that makes Vue so productive.