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.
@intlify/core
Advanced tools
@intlify/core is a core library for internationalization (i18n) in JavaScript applications. It provides essential functionalities for managing translations, formatting messages, and handling locale-specific data. This package is part of the Intlify project, which aims to offer a comprehensive solution for i18n in modern web applications.
Creating an i18n instance
This feature allows you to create an i18n instance with specified locales and messages. The i18n instance can then be used to manage translations in your application.
const { createI18n } = require('@intlify/core');
const i18n = createI18n({
locale: 'en',
messages: {
en: { welcome: 'Welcome' },
fr: { welcome: 'Bienvenue' }
}
});
Translating messages
This feature allows you to translate messages based on the current locale. The `t` method is used to fetch the translated message for a given key.
const message = i18n.t('welcome');
console.log(message); // Output: 'Welcome'
Changing locale
This feature allows you to change the current locale of the i18n instance. Once the locale is changed, all subsequent translations will be based on the new locale.
i18n.locale = 'fr';
const message = i18n.t('welcome');
console.log(message); // Output: 'Bienvenue'
i18next is a popular internationalization framework for JavaScript. It provides similar functionalities to @intlify/core, such as managing translations, handling locales, and formatting messages. i18next is known for its extensive plugin system and support for various frameworks like React, Vue, and Angular.
react-intl is a library specifically designed for internationalization in React applications. It offers components and APIs to manage translations, format messages, and handle locale-specific data. While it is similar to @intlify/core in terms of functionality, react-intl is tailored for React and provides a more integrated experience for React developers.
vue-i18n is an internationalization plugin for Vue.js applications. It provides functionalities for managing translations, handling locales, and formatting messages. vue-i18n is similar to @intlify/core but is specifically designed for Vue.js, offering seamless integration with Vue components and the Vue ecosystem.
The intlify core module for i18n
core(.runtime).global(.prod).js
:
<script src="...">
in the browser. Exposes the IntlifyCore
global<script src="...">
core.global.js
is the "full" build that includes both the compiler and the runtime so it supports compiling locale messages on the flycore.runtime.global.js
contains only the runtime and requires locale messages to be pre-compiled during a build step@intlify/shared
@intlify/message-compiler
*.prod.js
files for productioncore(.runtime).esm-browser(.prod).js
:
<script type="module">
)core(.runtime).esm-bundler.js
:
webpack
, rollup
and parcel
process.env.NODE_ENV
guards (must be replaced by bundler)@intlify/message-compiler
)
esm-bundler
builds and will in turn import their dependencies (e.g. @intlify/message-compiler
imports @intlify/shared
)core.runtime.esm-bundler.js
(default) is runtime only, and requires all locale messages to be pre-compiled. This is the default entry for bundlers (via module
field in package.json
) because when using a bundler templates are typically pre-compiled (e.g. in *.json
files)core.esm-bundler.js
: includes the runtime compiler. Use this if you are using a bundler but still want locale messages compilation (e.g. templates via inline JavaScript strings)core.cjs(.prod).js
:
require()
target: 'node'
and properly externalize @intlify/core
, this is the build that will be loadedprocess.env.NODE_ENV
FAQs
@intlify/core
The npm package @intlify/core receives a total of 76,127 weekly downloads. As such, @intlify/core popularity was classified as popular.
We found that @intlify/core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.