Skip to content

Compiler-based i18n library that emits tree-shakable translations, leading to up to 70% smaller bundle sizes.

License

Notifications You must be signed in to change notification settings

opral/paraglide-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2,050 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NPM Downloads GitHub Issues Contributors Discord

πŸͺ‚ Paraglide JS

Compiler-based i18n library that emits tree-shakable translations, leading to up to 70% smaller i18n bundle sizes.

Documentation Β· Quick Start Β· Report Bug

Used in production by

MichelinΒ Β Β  IdealistaΒ Β Β  ArchitonicΒ Β Β  0.emailΒ Β Β  ...and more

Trusted by framework authors

Svelte SvelteKit's official i18n integration
TanStack Part of TanStack's CI pipeline

Code Preview

// messages/en.json
{
  "greeting": "Hello {name}!"
}
import { m } from "./paraglide/messages.js";

m.greeting({ name: "World" }); // "Hello World!" β€” fully typesafe

The compiler generates typed message functions. Your bundler tree-shakes unused messages. Expect up to 70% smaller i18n bundle sizes compared to runtime i18n libraries (e.g. 47 KB vs 205 KB).

Why Paraglide?

Smaller i18n Bundle Up to 70% smaller i18n bundle size than runtime i18n libraries.
Tree-Shakable Unused messages are eliminated by your bundler.
Fully Typesafe Autocomplete for message keys and parameters. Typos become compile errors.
Framework Agnostic Works with React, Vue, Svelte, Solid, TanStack, or vanilla JS/TS.
Built-in i18n Routing URL-based locale detection and localized paths out of the box.
Built on inlang Integrates with Sherlock (VS Code extension), Fink (translation editor), and more.

Works With Your Stack

React React Β· Vue Vue Β· TanStack TanStack Start Β· Svelte SvelteKit Β· React Router React Router Β· Astro Astro Β· JavaScript Vanilla JS/TS

Tip

Vite Paraglide is ideal for any Vite based app. Setup is just one plugin and Vite's tree-shaking eliminates unused messages automatically. Get started β†’

Quick Start

npx @inlang/paraglide-js init

The CLI sets up everything:

  • Creates your message files
  • Configures your bundler (Vite, Webpack, etc.)
  • Generates typesafe message functions

Then use your messages:

import { m } from "./paraglide/messages.js";
import { setLocale, getLocale } from "./paraglide/runtime.js";

// Use messages (typesafe, with autocomplete)
m.hello_world();
m.greeting({ name: "Ada" });

// Get/set locale
getLocale(); // "en"
setLocale("de"); // switches to German

Full Getting Started Guide β†’

How It Works

Paraglide compiles an inlang project into tree-shakable message functions. Your bundler eliminates unused messages at build time.

       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚ Inlang Project β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Paraglide Compiler    β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚
              β–Ό
 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
 β”‚ ./paraglide/messages.js  β”‚
 β”‚ ./paraglide/runtime.js   β”‚
 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Watch: How Paraglide JS works in 6 minutes β†’

Message Format

Paraglide supports locale-aware formatting via declaration formatters:

  • plural (Intl.PluralRules) for plural and ordinal categories
  • number (Intl.NumberFormat) for numbers, currency, compact notation, and more
  • datetime (Intl.DateTimeFormat) for dates/times with locale-aware output

Gender and custom selects are supported via the variants system.

// Pluralization example
m.items_in_cart({ count: 1 }); // "1 item in cart"
m.items_in_cart({ count: 5 }); // "5 items in cart"

// Works correctly for complex locales (Russian, Arabic, etc.)

Message format is plugin-based β€” use the default inlang format, or switch to i18next, JSON, or ICU MessageFormat via plugins. If your team relies on ICU MessageFormat 1 syntax, use the inlang-icu-messageformat-1 plugin.

Formatting Docs β†’ Β· Pluralization & Variants Docs β†’

Comparison

Feature Paraglide i18next react-intl
i18n bundle size Up to 70% smaller via tree-shaking ❌ Ships all messages ❌ Ships all messages
Tree-shakable βœ… ❌ ❌
Typesafe βœ… Partial ❌
Framework agnostic βœ… Wrappers needed React only
i18n routing βœ… Built-in ❌ ❌

Full Comparison β†’

What Developers Say

"Paraglide JS is by far the best option when it comes to internationalization. Nothing better on the market."

Ancient-Background17 Β· Reddit

"Just tried Paraglide JS. This is how i18n should be done! Totally new level of DX."

Patrik Engborg Β· @patrikengborg

"I was messing with various i18n frameworks and must say Paraglide was the smoothest experience. SSG and SSR worked out of the box."

Dalibor Hon Β· Discord

"I migrated from i18next. Paraglide reduced my i18n bundle from 40KB to ~2KB."

Daniel Β· Why I Replaced i18next with Paraglide JS

Talks

Ecosystem

Paraglide is built on the open inlang format. Works with:

Tool Description
Sherlock VS Code extension for inline translation editing
CLI Machine translate from the terminal
Fink Translation editor for non-developers
Parrot Manage translations in Figma

Explore the inlang ecosystem β†’

Documentation

Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

License

MIT β€” see LICENSE

About

Compiler-based i18n library that emits tree-shakable translations, leading to up to 70% smaller bundle sizes.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 42