paraglide
The preset for Paraglide JS. It reads m.key() message calls and messages/{locale}.json files.
The paraglide preset supports Paraglide JS from inlang.
Detection
The preset applies when the project depends on @inlang/paraglide-js, @inlang/paraglide-sveltekit, @inlang/paraglide-next, @inlang/paraglide-astro or @inlang/paraglide-vite.
x18n.config.ts
import { paraglide } from '@x18n/cli/presets'
import { defineConfig } from '@x18n/core'
export default defineConfig({
presets: [paraglide()],
})Locale files
If your config has no resources, the preset uses messages/{locale}.json.
Supported syntax
A message is a function on the m object. The name of the function is the key. The preset reads .js, .ts, JSX, Vue, Svelte and Astro files.
src/routes/+page.svelte
<h1>{m.hello_world({ name: 'Ada' })}</h1>
<p>{m['page.intro']()}</p>Placeholders
Single braces: {name}.
Extraction templates
| Kinds | Template | Imports |
|---|---|---|
jsx-text, svelte-text | {m.{key}({args})} | import { m } from '$lib/paraglide/messages' |
js-string, js-template | m.{key}({args}) | import { m } from '$lib/paraglide/messages' |