You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@lingui/react

Package Overview
Dependencies
Maintainers
2
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lingui/react

React components for translations


Version published
Weekly downloads
127K
decreased by-20.98%
Maintainers
2
Created
Weekly downloads
 

Package description

What is @lingui/react?

@lingui/react is a library for internationalization (i18n) in React applications. It provides tools to manage translations, pluralization, and formatting of messages, making it easier to support multiple languages in your app.

What are @lingui/react's main functionalities?

Translation

This feature allows you to translate text in your React application. The `Trans` component is used to display translated messages based on the active locale.

import { I18nProvider, Trans } from '@lingui/react';
import { i18n } from '@lingui/core';
import { messages } from './locales/en/messages';

i18n.load('en', messages);
i18n.activate('en');

function App() {
  return (
    <I18nProvider i18n={i18n}>
      <Trans id="hello" />
    </I18nProvider>
  );
}

Pluralization

This feature handles pluralization of messages. The `Plural` component allows you to display different messages based on the count of items.

import { I18nProvider, Plural } from '@lingui/react';
import { i18n } from '@lingui/core';
import { messages } from './locales/en/messages';

i18n.load('en', messages);
i18n.activate('en');

function App() {
  const itemCount = 5;
  return (
    <I18nProvider i18n={i18n}>
      <Plural
        value={itemCount}
        one="{itemCount} item"
        other="{itemCount} items"
      />
    </I18nProvider>
  );
}

Message Formatting

This feature allows you to format messages with dynamic values. The `Trans` component can take a `values` prop to insert dynamic content into the translated message.

import { I18nProvider, Trans } from '@lingui/react';
import { i18n } from '@lingui/core';
import { messages } from './locales/en/messages';

i18n.load('en', messages);
i18n.activate('en');

function App() {
  const userName = 'John';
  return (
    <I18nProvider i18n={i18n}>
      <Trans id="welcome" values={{ name: userName }} />
    </I18nProvider>
  );
}

Other packages similar to @lingui/react

Changelog

Source

4.11.2 (2024-07-03)

Bug Fixes

  • cli: update translationIO service in CLI package (to handle context) (#1949) (ea7b9e7)
  • include type cast on ts compilation (#1962) (0f66617)

Readme

Source

License Version Downloads

@lingui/react

React components for internationalization

@lingui/react is part of LinguiJS. See the documentation for all information, tutorials and examples.

Installation

npm install --save @lingui/react
# yarn add @lingui/react

Usage

See the tutorial or reference documentation.

License

MIT

Keywords

FAQs

Package last updated on 03 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc