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

@intlify/core-base

Package Overview
Dependencies
Maintainers
2
Versions
154
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@intlify/core-base

@intlify/core-base


Version published
Weekly downloads
631K
decreased by-18.8%
Maintainers
2
Install size
1.10 MB
Created
Weekly downloads
 

Package description

What is @intlify/core-base?

@intlify/core-base is a core library for internationalization (i18n) in JavaScript applications. It provides essential functionalities for handling translations, message formatting, and locale management, making it easier to build multilingual applications.

What are @intlify/core-base's main functionalities?

Basic Translation

This feature allows you to define translations for different locales and switch between them. The code sample demonstrates how to create a context with messages in English and French, and how to switch the locale to get the translated message.

const { createCoreContext, translate } = require('@intlify/core-base');

const ctx = createCoreContext({
  locale: 'en',
  messages: {
    en: {
      hello: 'Hello, world!'
    },
    fr: {
      hello: 'Bonjour, le monde!'
    }
  }
});

console.log(translate(ctx, 'hello')); // Output: Hello, world!
ctx.locale = 'fr';
console.log(translate(ctx, 'hello')); // Output: Bonjour, le monde!

Message Formatting

This feature allows you to use placeholders in your messages and replace them with dynamic values. The code sample shows how to define a message with a placeholder and provide a value for it during translation.

const { createCoreContext, translate } = require('@intlify/core-base');

const ctx = createCoreContext({
  locale: 'en',
  messages: {
    en: {
      greeting: 'Hello, {name}!'
    }
  }
});

console.log(translate(ctx, 'greeting', { name: 'Alice' })); // Output: Hello, Alice!

Locale Management

This feature provides the ability to manage the current locale and fallback locales. The code sample demonstrates how to set and get the current locale and how to define a fallback locale.

const { createCoreContext } = require('@intlify/core-base');

const ctx = createCoreContext({
  locale: 'en',
  fallbackLocale: 'fr',
  messages: {
    en: {
      hello: 'Hello, world!'
    },
    fr: {
      hello: 'Bonjour, le monde!'
    }
  }
});

console.log(ctx.locale); // Output: en
ctx.locale = 'fr';
console.log(ctx.locale); // Output: fr

Other packages similar to @intlify/core-base

Changelog

Source

v9.10.1 (2024-03-01T01:26:17Z)

This changelog is generated by GitHub Releases

<!-- Release notes generated using configuration in .github/release.yml at v9.10.1 -->

What's Changed

⚡ Improvement Features

  • chore(fix): #1630 make the install function synchronous to be aligned… by @k-paxian in https://github.com/intlify/vue-i18n-next/pull/1631

📝️ Documentations

  • docs: wrong te docs by @kazupon in https://github.com/intlify/vue-i18n-next/pull/1753

New Contributors

  • @k-paxian made their first contribution in https://github.com/intlify/vue-i18n-next/pull/1631

Full Changelog: https://github.com/intlify/vue-i18n-next/compare/v9.10.0...v9.10.1

Readme

Source

@intlify/core-base

The intlify core base module

MIT

Keywords

FAQs

Package last updated on 01 Mar 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