npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@inlang/paraglide-sveltekit

v0.15.0

Published

[![Inlang-ecosystem compatibility badge](https://cdn.jsdelivr.net/gh/opral/monorepo@main/inlang/assets/md-badges/inlang.svg)](https://inlang.com)

Downloads

40,354

Readme

Inlang-ecosystem compatibility badge

Getting Started

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.

  • Create an Inlang Project
  • Create translation files for each of your languages
  • Add necessary Provider Components and files
  • Update your 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.

Creating Messages

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.

Using messages in Code

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.

Language detection

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 - German

The 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