[SvelteKit]

Add missing strings to an existing svelte-i18n setup

Polyglot reads your register() calls, resolves the exact catalog files your app loads, and merges new keys into them — order preserved, existing translations untouched.

1 Min. LesezeitAlle Frameworks

An existing svelte-i18n app has its own catalog files, its own init module, its own conventions. The only correct automation is one that joins your world: Polyglot statically resolves the JSON files from your register('en', () => import('./locales/en.json')) calls and merges new keys into those files.

The transformation

Before — src/routes/+page.svelte
<script>
  import { _ } from 'svelte-i18n';
</script>

<h1>Welcome back</h1>
<p>{$_('nav.home')}</p>
After — src/routes/+page.svelte
<script>
  import { _, t } from 'svelte-i18n';
</script>

<h1>{$t('src.routes.+page.welcome_back')}</h1>
<p>{$_('nav.home')}</p>

Note the import: your file already imported { _ } from svelte-i18n, so Polyglot extended that import with t (its alias) rather than duplicating or breaking it.

Merged into YOUR catalogs

Merged into — src/lib/locales/de.json
{
  "nav": {
    "home": "Startseite"
  },
  "src": {
    "routes": {
      "+page": {
        "welcome_back": "Welcome back"
      }
    }
  }
}
Merged into — src/lib/locales/en.json
{
  "nav": {
    "home": "Home"
  },
  "src": {
    "routes": {
      "+page": {
        "welcome_back": "Welcome back"
      }
    }
  }
}
  • Key order and formatting are preserved — merges are textual, never a re-serialization that scrambles your diff.
  • Every other locale you register gets an English stub for the new key so nothing renders raw until you run polyglot translate.
  • If your dictionaries are inline or your loader paths are computed, Polyglot flags the strings with a recipe instead of writing files your app would never load.
✓ 1 strings auto-wrapped · 0 flagged for manual review · 0 unsafe transforms → polyglot-i18n-report.md
✓ wiring checks passed (1 injected import(s), 1 catalog value(s), 2 catalog file(s))

Try it

$ curl -fsSL https://getpolyglot.ai/install.sh | bash
$ 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 | bash
Add missing strings to an existing svelte-i18n setup | Polyglot