Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lingui/core

Package Overview
Dependencies
Maintainers
1
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lingui/core

I18n tools for javascript

  • 3.10.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
296K
decreased by-9.31%
Maintainers
1
Weekly downloads
 
Created

What is @lingui/core?

@lingui/core is a library for internationalization (i18n) in JavaScript applications. It provides tools for managing translations, formatting messages, and handling locale data. It is designed to be flexible and easy to integrate with various frameworks and libraries.

What are @lingui/core's main functionalities?

Message Formatting

This feature allows you to format messages with placeholders that can be replaced with dynamic values. The example demonstrates loading a translation, activating a locale, and formatting a message with a dynamic name.

const { i18n } = require('@lingui/core');
const { setupI18n } = require('@lingui/core');

const i18n = setupI18n();
i18n.load({
  en: {
    message: 'Hello, {name}!'
  }
});
i18n.activate('en');

const message = i18n._('message', { name: 'John' });
console.log(message); // Output: Hello, John!

Locale Management

This feature allows you to manage different locales and switch between them. The example shows how to load translations for multiple locales and activate a specific locale to get the translated message.

const { i18n } = require('@lingui/core');
const { setupI18n } = require('@lingui/core');

const i18n = setupI18n();
i18n.load({
  en: { message: 'Hello' },
  fr: { message: 'Bonjour' }
});
i18n.activate('fr');

const message = i18n._('message');
console.log(message); // Output: Bonjour

Custom Pluralization Rules

This feature allows you to define custom pluralization rules for different languages. The example demonstrates how to use pluralization in a message based on the count value.

const { i18n } = require('@lingui/core');
const { setupI18n } = require('@lingui/core');

const i18n = setupI18n();
i18n.load({
  en: {
    message: '{count, plural, one {# item} other {# items}}'
  }
});
i18n.activate('en');

const message = i18n._('message', { count: 5 });
console.log(message); // Output: 5 items

Other packages similar to @lingui/core

Keywords

FAQs

Package last updated on 08 Jun 2021

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

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc