[ SvelteKit ]

Wrap SvelteKit pages for svelte-i18n automatically

Pages get {$t()} calls, the init module is scaffolded with SSR-safe static imports, and the root layout is wired — verified at the end of every run.

1 Min. LesezeitAlle Frameworks

svelte-i18n's classic SSR trap is lazy register() loaders: the server render asks for a message before the dictionary resolves. Polyglot's scaffold sidesteps it with static imports + synchronous addMessages — the server render always has its dictionary.

The transformation

Before — src/routes/+page.svelte
<main>
  <h1>Welcome back</h1>
  <p>Your projects are ready</p>
</main>
After — src/routes/+page.svelte
<script>
  import { t } from 'svelte-i18n';
</script>

<main>
  <h1>{$t('src.routes.+page.welcome_back')}</h1>
  <p>{$t('src.routes.+page.your_projects_are_ready')}</p>
</main>

Setup, scaffolded and wired

The generated init module and the root +layout.svelte wiring land together, and the run verifies both:

Written — messages/en.json
{
  "src": {
    "routes": {
      "+page": {
        "welcome_back": "Welcome back",
        "your_projects_are_ready": "Your projects are ready"
      }
    }
  }
}
Translated — messages/de.json
{
  "src": {
    "routes": {
      "+page": {
        "welcome_back": "Willkommen zurück",
        "your_projects_are_ready": "Ihre Projekte sind bereit"
      }
    }
  }
}
Translated — messages/fr.json
{
  "src": {
    "routes": {
      "+page": {
        "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))

Already using svelte-i18n?

Polyglot reads your register() calls, resolves your catalog files, and merges into them — see the existing-setup page for that flow.

Try it

$ curl -fsSL https://getpolyglot.ai/install.sh | sh
$ polyglot init --framework sveltekit
$ 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 SvelteKit pages for svelte-i18n automatically | Polyglot