Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@lingui/react
Advanced tools
@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.
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>
);
}
react-intl is a popular library for internationalization in React applications. It provides components and an API to format dates, numbers, and strings, and to handle pluralization and translations. Compared to @lingui/react, react-intl has a larger community and more extensive documentation, but @lingui/react offers a more modern and flexible approach to message management.
i18next is a powerful internationalization framework that can be used with various JavaScript libraries, including React. It offers a wide range of features, such as language detection, interpolation, and pluralization. While i18next is more versatile and can be used outside of React, @lingui/react is specifically designed for React applications, making it easier to integrate and use within a React project.
react-i18next is a React binding for i18next, providing components and hooks to use i18next in React applications. It offers similar functionalities to @lingui/react, such as translation, pluralization, and context-based translations. However, @lingui/react has a more streamlined API and better integration with modern React features like hooks.
React components for internationalization
@lingui/react
is part of LinguiJS. See the documentation for all information, tutorials and examples.
npm install --save @lingui/react
# yarn add @lingui/react
See the tutorial or reference documenation.
3.0.2 (2020-11-01)
<a name="3.0.1"></a>
FAQs
React components for translations
The npm package @lingui/react receives a total of 89,045 weekly downloads. As such, @lingui/react popularity was classified as popular.
We found that @lingui/react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.