Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@lingui/macro
Advanced tools
@lingui/macro is a package that provides macros for internationalization (i18n) in JavaScript and React applications. It allows developers to mark strings for translation and handle pluralization, among other i18n tasks, in a way that integrates seamlessly with the LinguiJS framework.
Translation
The `t` macro is used to mark strings for translation. This allows the string to be extracted and translated into different languages.
import { t } from '@lingui/macro';
const message = t`Hello, World!`;
Pluralization
The `plural` macro handles pluralization based on a count. It allows you to define different strings for singular and plural forms.
import { plural } from '@lingui/macro';
const message = plural(count, {
one: '# book',
other: '# books'
});
Select
The `select` macro is used for gender-based or other categorical selections. It allows you to define different strings based on the value of a variable.
import { select } from '@lingui/macro';
const message = select(gender, {
male: 'He is a developer.',
female: 'She is a developer.',
other: 'They are a developer.'
});
Date and Time Formatting
The `date` macro formats dates according to the specified options. This is useful for displaying dates in a localized format.
import { date } from '@lingui/macro';
const message = date(new Date(), {
year: 'numeric',
month: 'long',
day: 'numeric'
});
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/macro, react-intl is more component-based and may require more boilerplate code.
i18next is a full-featured i18n framework for JavaScript. It supports translation, pluralization, and formatting, and can be used with various front-end frameworks including React. i18next is more flexible and can be used in a wider range of environments compared to @lingui/macro, which is more tightly integrated with LinguiJS.
formatjs is a set of libraries for internationalization in JavaScript, including react-intl. It provides low-level APIs for formatting dates, numbers, and strings, and for handling pluralization and translations. formatjs offers more granular control over i18n tasks compared to @lingui/macro.
Babel Macros which transforms tagged template literals and JSX components to ICU MessageFormat.
@lingui/macro
is part of LinguiJS. See the documentation for all information, tutorials and examples.
See the reference documentation.
FAQs
Macro for generating messages in ICU MessageFormat syntax
We found that @lingui/macro 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.