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

i18n-js

Package Overview
Dependencies
Maintainers
2
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-js

A javascript library similar to Ruby on Rails i18n gem

  • 3.0.8
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
303K
decreased by-2.5%
Maintainers
2
Weekly downloads
 
Created

What is i18n-js?

The i18n-js npm package is a lightweight internationalization library for JavaScript. It allows developers to easily manage translations and localization in their applications. The package supports features like translation lookup, interpolation, pluralization, and more.

What are i18n-js's main functionalities?

Translation Lookup

This feature allows you to look up translations based on the current locale. You can define translations for different languages and switch between them easily.

const I18n = require('i18n-js');
I18n.translations = {
  en: { greeting: 'Hello' },
  fr: { greeting: 'Bonjour' }
};
I18n.locale = 'en';
console.log(I18n.t('greeting')); // Output: 'Hello'
I18n.locale = 'fr';
console.log(I18n.t('greeting')); // Output: 'Bonjour'

Interpolation

Interpolation allows you to insert dynamic values into your translations. This is useful for personalizing messages or including variable data in your translations.

const I18n = require('i18n-js');
I18n.translations = {
  en: { greeting: 'Hello, %{name}' }
};
I18n.locale = 'en';
console.log(I18n.t('greeting', { name: 'John' })); // Output: 'Hello, John'

Pluralization

Pluralization allows you to handle different translations based on the count of items. This is useful for correctly displaying singular and plural forms of words.

const I18n = require('i18n-js');
I18n.translations = {
  en: { messages: { one: 'You have 1 message', other: 'You have %{count} messages' } }
};
I18n.locale = 'en';
console.log(I18n.t('messages', { count: 1 })); // Output: 'You have 1 message'
console.log(I18n.t('messages', { count: 5 })); // Output: 'You have 5 messages'

Other packages similar to i18n-js

Keywords

FAQs

Package last updated on 06 Jun 2018

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