lingui /js-lingui

🌍 📖 A readable, automated, and optimized (2 kb) internationalization for JavaScript

★ 5,937⑂ 478👁 30⑃ 1,425● 1,178▤ 158
TypeScriptMITCreated 2017-01-17lingui.dev
下载:v6.12.0v6.12.0 ↓6.12.02026-11-03
+0
日增长
5,937
stars
478
forks
30
watchers
1,425
prs
1,178
issues
158
releases

README

Linguijs

Lingui is a lightweight, open-source internationalization (i18n) library for JavaScript and TypeScript. It brings compile-time macros and a CLI for message extraction to React, React Native, Vue, SolidJS, Astro, Svelte, and Node.js.

About 2 kB gzipped core · 6M+ npm downloads a month · MIT licensed



![Main Suite][Badge-MainSuite-GithubCI]
![Release Workflow Testing][Badge-ReleaseWorkflowTesting-GithubCI]
[![Code Coverage][Badge-Coverage]][Coverage]
[![PRs Welcome][Badge-PRWelcome]][PRWelcome]
[![Join the community on Discord][Badge-Discord]][Discord]

[Documentation][Documentation] · Quick Start · Why Lingui · Support · Contribute · License



 Quick Start

bash
npm install @lingui/core @lingui/react
npm install --save-dev @lingui/cli


Lingui macros run at build time, so add the macro plugin for your transpiler and create a lingui.config.js. The installation guide covers both in a few minutes.

Then wrap the text you want to translate in the Trans macro. There are no message IDs to invent and no separate JSON file to keep in sync:

jsx
import { i18n } from "@lingui/core"
import { I18nProvider } from "@lingui/react"
import { Trans } from "@lingui/react/macro"
import { messages } from "./locales/en/messages"

i18n.load("en", messages)
i18n.activate("en")

export function App() {
  return (
    
      
        Read the documentation for more info.
      
    
  )
}


Extract the messages into PO catalogs, translate them, then compile the catalogs into optimized runtime output:

bash
npx lingui extract
npx lingui compile


After translation, the Czech catalog in src/locales/cs/messages.po looks like this. The  tag stands for the  element, so translators never touch your markup:

po
: src/App.jsx:12
msgid "Read the documentation for more info."
msgstr "Přečtěte si dokumentaci pro více informací."


Continue with the React tutorial, or jump to React Server Components, React Native, SolidJS, Vue, or plain JavaScript. Working projects for Vite, Next.js, Remix, TanStack Start, React Native and more live in the examples directory.

 Why Lingui

In key-based i18n libraries you invent a key, put the text in a JSON file, and reference the key from the code. With Lingui, the text stays where it is read:

jsx
// Key-based i18n: the code holds a key, the text lives somewhere else
{t("dashboard.welcome.title")}

// Lingui: the text is the source of truth, the catalog is generated from it

  Welcome back, {name}



The code reads like the UI it renders, and reviewers see the actual copy in the diff. Nobody has to name keys or look up what a key means. Running lingui extract regenerates the catalog from the source, so new messages are added and removed ones are marked obsolete without any manual bookkeeping. Translators get the real sentence with named placeholders, plus any comments and context you add. Message IDs are stable hashes generated at build time, and explicit IDs are available when you need them.

On top of that:

- Rich text without worka

Top issues

Discussions

Latest release

v6.12.0 v6.12.0 2026-11-03
6.12.0 (2026-11-03)

 Features

 core: support custom ICU formatters (2721) (fb41433) (Announcement)

 Bug Fixes

 cli: don't crash orderBy "origin" on messages without origin (2760) (842f361)
 vite-plugin: support @rolldown/plugin-babel 0.3 (2761) (cbf16e9)

Snapshot: 2026-11-16T09:23:14Z · Data license Apache-2.0 · JSON