@lingui/core

The Lingui i18n runtime: loads compiled message catalogs, tracks the active locale and formats ICU MessageFormat messages

@lingui/core downloads @lingui/core version @lingui/core license

@lingui/coreSimilar Packages:

Npm Package Weekly Downloads Trend

3 Years
🌟 Show real-time usage chart on @lingui/core's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of @lingui/core](https://npm-compare.com/img/npm-trend/THREE_YEARS/@lingui/core.png)](https://npm-compare.com/@lingui/core#timeRange=THREE_YEARS)

Cumulative GitHub Star Trend

🌟 Show GitHub stars trend chart on @lingui/core's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of @lingui/core](https://npm-compare.com/img/github-trend/@lingui/core.png)](https://npm-compare.com/@lingui/core)

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
@lingui/core05,88030.3 kB666 days agoMIT

README for @lingui/core

License Version Downloads

@lingui/core

The Lingui i18n runtime: loads compiled message catalogs, tracks the active locale and formats ICU MessageFormat messages

@lingui/core is part of Lingui. 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.

The package is framework-agnostic and behaves the same in the browser, in Node.js and inside any UI framework. @lingui/core exports the i18n instance, which loads catalogs, activates a locale and translates messages. @lingui/core/macro exports the t, plural, select and related macros, which are compiled into ICU messages at build time and need the Babel or SWC plugin.

Usage

import { i18n } from "@lingui/core"
import { t } from "@lingui/core/macro"
import { messages } from "./locales/cs/messages"

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

function greeting(name) {
  return t`Hello ${name}`
}

greeting("Fred") // "Ahoj Fred"

The messages module is produced by lingui extract and lingui compile from @lingui/cli. Catalogs are compiled ahead of time, so the runtime ships without a MessageFormat parser.

The JavaScript tutorial walks through this setup. React projects use @lingui/react on top of this package. See the core reference and the macro reference for the full API.

License

This package is licensed under the MIT license.