
Security News
npm ‘is’ Package Hijacked in Expanding Supply Chain Attack
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
@inlang/paraglide-sveltekit
Advanced tools
--- imports: - https://cdn.jsdelivr.net/npm/@opral/markdown-wc-doc-elements/dist/doc-callout.js ---
imports:
Paraglide JS 2.0 doesn't need the SvelteKit adapter anymore. Please use the [Paraglide JS 2.0](https://inlang.com/m/gerre34r/library-inlang-paraglideJs/sveltekit) directly.Paraglide JS 2.0 doesn't need the SvelteKit adapter anymore. Please use the Paraglide JS 2.0 directly.
Get started instantly with the Paraglide-SvelteKit CLI.
npx @inlang/paraglide-sveltekit init
npm install
The CLI will ask you which languages you want to support. This can be changed later.
vite.config.js
file to use the Paraglide-SvelteKit Plugin.You can now start your development server and visit /de
, /ar
, or whatever languages you've set up.
Your messages live in messages/{languageTag}.json
files. You can add messages in these files as key-value pairs of the message ID and the translations.
Use curly braces to add parameters.
// messages/en.json
{
// The $schema key is automatically ignored
"$schema": "https://inlang.com/schema/inlang-message-format",
"hello_world": "Hello World!",
"greetings": "Greetings {name}."
}
Learn more about the format in the Inlang Message Format Documentation.
Note: All messages you use in your project must be added to these files. It is not possible to dynamically add more messages at runtime.
The Paraglide compiler will generate a src/lib/paraglide/messages.js
file that contains your messages. Import messages from there. By convention, a wildcard import is used.
<script>
import * as m from '$lib/paraglide/messages.js'
</script>
<h1>{m.homepage_title()}</h1>
<p>{m.homepage_subtitle({ some: "param" })}</p>
Only messages used on the current page are sent to the client. Any messages that aren't used on the current page will be tree-shaken out.
## Accessing Language in Code
You can access the current language with the languageTag()
function.
<script>
import { languageTag } from '$lib/paraglide/runtime.js'
</script>
<h1>{languageTag()}</h1>
On the server languageTag()
is scoped to the current request, there is no danger of multiple requests interfering. languageTag()
can safely be called in server-load functions and form actions.
The language is determined based on the URL. If the first segment of the URL is a language tag, that language will be used. If no language tag is present, the default language will be used.
/about
- English/de/about
- GermanThe reroute
hook in src/hooks.js
(added automatically) automatically rewrites requests that include the language in the URL to the correct page. There is no need to modify your routes to add a [locale]
segment.
src/
routes/
+layout.svelte
+page.svelte
FAQs
--- imports: - https://cdn.jsdelivr.net/npm/@opral/markdown-wc-doc-elements/dist/doc-callout.js ---
The npm package @inlang/paraglide-sveltekit receives a total of 3,708 weekly downloads. As such, @inlang/paraglide-sveltekit popularity was classified as popular.
We found that @inlang/paraglide-sveltekit demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The ongoing npm phishing campaign escalates as attackers hijack the popular 'is' package, embedding malware in multiple versions.
Security News
A critical flaw in the popular npm form-data package could allow HTTP parameter pollution, affecting millions of projects until patched versions are adopted.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.