[ Vue ]

Wrap Vue templates for vue-i18n automatically

Templates get $t() calls, script setup gets useI18n, the i18n instance is scaffolded and wired into main.ts — and existing vue-i18n catalogs are merged into, not replaced.

1 Min. LesezeitAlle Frameworks

Polyglot wraps Vue SFCs with vue-i18n's native shapes — and if your app already uses vue-i18n, it detects your catalog's location and format and merges into it rather than inventing a parallel one.

The transformation

Before — src/App.vue
<template>
  <main>
    <h1>Welcome back</h1>
    <p>Your projects are ready</p>
  </main>
</template>
After — src/App.vue
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
const { t } = useI18n();
</script>

<template>
  <main>
    <h1>{{ t('src.App.welcome_back') }}</h1>
    <p>{{ t('src.App.your_projects_are_ready') }}</p>
  </main>
</template>
  • Template text becomes {{ $t('key') }}; bound attributes get :attr="$t('key')" conversions.
  • Components that need it get the useI18n binding so both template and script resolve.
  • Rich inline formatting (text with <strong>/links inside) is flagged for review with the exact reason, never approximated — rich-text codegen ships for the React family; in Vue, Polyglot won't guess at markup.

Setup, scaffolded and wired

On a fresh app Polyglot creates the i18n instance and wires app.use(i18n) into src/main.ts — then verifies that wiring as part of the run:

Written — messages/en.json
{
  "src": {
    "App": {
      "welcome_back": "Welcome back",
      "your_projects_are_ready": "Your projects are ready"
    }
  }
}
Translated — messages/de.json
{
  "src": {
    "App": {
      "welcome_back": "Willkommen zurück",
      "your_projects_are_ready": "Ihre Projekte sind bereit"
    }
  }
}
Translated — messages/fr.json
{
  "src": {
    "App": {
      "welcome_back": "Bon retour",
      "your_projects_are_ready": "Vos projets sont prêts"
    }
  }
}
✓ 2 strings auto-wrapped · 0 flagged for manual review · 0 unsafe transforms → polyglot-i18n-report.md
✓ wiring checks passed (1 injected import(s), 2 catalog value(s), 1 catalog file(s))

Try it

$ curl -fsSL https://getpolyglot.ai/install.sh | sh
$ polyglot init --framework vue
$ polyglot scan
$ polyglot wrap
$ polyglot translate --languages de   # 50 strings free, no signup

Im Terminal starten

Schluss mit der Suche nach unübersetzten Strings.

Installieren Sie die CLI, führen Sie einen Scan durch und sehen Sie genau, was Ihnen fehlt. Kostenlos, kein Konto erforderlich.

$curl -fsSL https://getpolyglot.ai/install.sh | sh
Wrap Vue templates for vue-i18n automatically | Polyglot