lingui/js-lingui

TypeScriptlingui.dev
AndroidiOS

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

translationinternationalizationjavascripti18nlocalizationreactreact-componentsmessageformatintlreact-nativenextjssolidjs
스타 성장
스타
5.9k
포크
457
주간 성장
+8
이슈
47
2k4k
2023년 1월2024년 3월2025년 6월2026년 9월
아티팩트npm
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 Release Workflow Testing Code Coverage PRs Welcome Join the community on Discord

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

Quick Start

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:

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 (
    <I18nProvider i18n={i18n}>
      <Trans>
        Read the <a href="https://lingui.dev">documentation</a> for more info.
      </Trans>
    </I18nProvider>
  )
}

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

npx lingui extract
npx lingui compile

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

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

Continue with the React tutorial, or jump to React Server Components, React Native, SolidJS, 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:

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

// Lingui: the text is the source of truth, the catalog is generated from it
<h1>
  <Trans>Welcome back, {name}</Trans>
</h1>

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 workarounds. React components inside a message are as easy as writing JSX. Translators see numbered tags, and the catalog stays in sync with your components.

  • Compiled, not parsed at runtime. Catalogs are compiled ahead of time, so the runtime ships without a MessageFormat parser. Core @lingui/core, React bindings @lingui/react.

  • One library for the whole stack. @lingui/core works in any JavaScript project. @lingui/react adds components and hooks, including React Server Components support, and @lingui/solid brings native SolidJS bindings. React Native uses the same extract-and-compile workflow, Vue single-file components are supported through @lingui/extractor-vue, and Astro and Svelte work through community packages.

  • Standard formats and real tooling. Translations live in PO files by default, which almost every translation tool understands, or in JSON, CSV, or a custom format. Messages carry comments and context for translators and machine translation. The CLI extracts, compiles and validates, the Vite plugin compiles catalogs on the fly, the SWC plugin replaces Babel, and the ESLint plugin catches common mistakes.

Who Uses Lingui

Lingui runs in production at Bluesky, ElevenLabs, Linkerd, GDevelop, Documenso, Gamma, Twenty, Superset, Notesnook, Inkeep and many more. See the showroom for more, and add your project if it is missing.

Requirements

  • Node.js 22.19 or newer.
  • Lingui 6 packages are ESM-only, except @lingui/metro-transformer, which stays CommonJS. Modern bundlers and Node.js versions with require(esm) handle this transparently. See the migration guide.
  • Macros need Babel with @lingui/babel-plugin-lingui-macro or SWC with @lingui/swc-plugin.
  • @lingui/react supports React 16.14 and newer, including React 19.

Docs for AI Agents

  • Every documentation page is available as Markdown by appending .md to its URL, for example lingui.dev/installation.md.
  • lingui.dev/llms.txt indexes the docs and lingui.dev/llms-full.txt contains them in full.
  • Context7 serves the latest docs over MCP. Add use context7 to a prompt.
  • lingui/skills packages Lingui best practices as Agent Skills for Claude Code, Cursor, Codex, Gemini CLI, GitHub Copilot and other compatible agents. Install with npx skills add lingui/skills.

See i18n with AI for the details.

Support

If you are having issues, please let us know.

  • Join us on Discord to chat with the community.
  • Ask questions on StackOverflow and mark it with the linguijs tag.
  • If something doesn't work as documented, documentation is missing or if you just want to suggest a new feature, create an issue.
  • You can also Ask Lingui JS Guru, it is a Lingui JS focused AI to answer your questions.

Contribute

Contribution to open-source project is everything from spreading the word, writing documentation to implement features and fixing bugs.

  • Do you use Lingui in production site? Let us know!
  • Have you seen any interesting talk or article about i18n? Share it!
  • Have you found a bug or do you want to suggest a new feature? Create an issue!
  • Do you want to improve the docs and write some code? Read the contributors guide and send a PR!

Contributors

This project exists thanks to all the people who contribute. [Contribute].

License

The project is licensed under the MIT license.

관련 저장소
TeamNewPipe/NewPipe

A libre lightweight streaming front-end for Android.

JavaMavenGNU General Public License v3.0youtube-videovideo
newpipe.net
39.6k3.8k
PDFMathTranslate/PDFMathTranslate

[EMNLP 2025 Demo] PDF scientific paper translation with preserved formats - 基于 AI 完整保留排版的 PDF 文档全文双语翻译,支持 Google/DeepL/Ollama/OpenAI 等服务,提供 CLI/GUI/MCP/Docker/Zotero

PythonPyPIappGNU Affero General Public License v3.0chineselatex
pdf2zh.com
36.8k3.3k
ryanhanwu/How-To-Ask-Questions-The-Smart-Way

本文原文由知名 Hacker Eric S. Raymond 所撰寫,教你如何正確的提出技術問題並獲得你滿意的答案。

JavaScriptnpmtutorialMIT Licensertfmtranslation
35.7k5.8k
unknwon/the-way-to-go_ZH_CN

《The Way to Go》中文译本,中文正式名《Go 入门指南》

GoGo Modulestutorialgotutorial
35k8.5k
xitu/gold-miner

🥇掘金翻译计划,可能是世界最大最好的英译中技术社区,最懂读者和译者的翻译平台:

tutorialandroidtranslation
juejin.cn/tag/%E6%8E%98%E9%87%91%E7%BF%BB%E8%AF%91%E8%AE%A1%E5%88%92
34.3k5k
nextai-translator/nextai-translator

基于 ChatGPT API 的划词翻译浏览器插件和跨平台桌面端应用 - Browser extension and cross-platform desktop application for translation based on ChatGPT API.

TypeScriptnpmappGNU Affero General Public License v3.0chatgptchrome-extension
25k1.9k
izackwu/TeachYourselfCS-CN

TeachYourselfCS 的中文翻译 | A Chinese translation of TeachYourselfCS

tutorialCreative Commons Attribution Share Alike 4.0 Internationaltranslationchinese-translation
teachyourselfcs.com
22.2k3.3k
go-playground/validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving

GoGo ModuleslibraryMIT Licensevalidationtranslation
20.2k1.5k
pot-app/pot-desktop

🌈一个跨平台的划词翻译和OCR软件 | A cross-platform software for text translation and recognition.

JavaScriptnpmGNU General Public License v3.0translationpot
pot-app.com
19.4k995
immersive-translate/immersive-translate

沉浸式双语网页翻译扩展 , 支持输入框翻译, 鼠标悬停翻译, PDF, Epub, 字幕文件, TXT 文件翻译 - Immersive Dual Web Page Translation Extension

appchrome-extensionsafari-extension
immersivetranslate.com
18.8k1.1k
LibreTranslate/LibreTranslate

Free and Open Source Machine Translation API. Self-hosted, offline capable and easy to setup.

PythonPyPIGNU Affero General Public License v3.0translationtranslate
libretranslate.com
16.3k1.7k
NVIDIA/DeepLearningExamples

State-of-the-Art Deep Learning scripts organized by models - easy to train and deploy with reproducible accuracy and performance on enterprise-grade infrastructure.

Jupyter Notebookcomputer-visiondeep-learning
14.8k3.4k