Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
messages-modules
Advanced tools
Messages (localized strings) that are scoped locally.
Add the package as a dependency:
npm install messages-modules
⚠️ Note that while this package offers simplistic plugin implementations of
messages-modules
, we do not recommend using them as-is.
We have 2 audiences in mind: internationalization (i18n) packages or advanced users who built their own i18n library in their projects.
Building an i18n library is not a simple task, as a lot of linguistics aspects (e.g., multi-plurals, inline markup) are easy to get wrong. messages-module
has been built with customization in mind, as you can:
If you are interested to see a mature i18n library using messages-modules
, check out next-multilingual
.
In a nutshell, messages-module
relies on compiler plugins to inject messages automatically to avoid writing a lot of boilerplate code like this:
import enUs from './my-file.en-US.json'
import frCa from './my-file.fr-CA.json'
// .. imagine 20 other languages (imports) here depending on your project...
import { Messages } from './messages'
const messages = new Messages([enUs, frCa /** the list goes on... */])
console.log(messages.format('en-US', 'greeting'))
Now imagine a React application where you have to add this boilerplate code in all your files using messages... And imagine add/removing languages. This is just a disaster waiting to happen.
What we are proposing instead is this simplified syntax, by injecting messages automatically in the functions you want:
import { getMessages } from './messages'
const messages = getMessages()
console.log(messages.format('en-US', 'greeting'))
To keep this simple, the message-modules
plugins only support named imports and named exports. This means that namespace imports, dynamic imports and require imports are out of scope:
👍 Supported
// Named import
import { getMessages } from 'messages-modules'
// Named export (used for shared messages)
export { getMessages } from 'messages-modules'
👎 Unsupported
// Namespace import
import * as messagesModules from 'messages-modules'
// Dynamic imports
const { getMessages } = await import('messages-modules')
// Require imports
const messagesModules = require('messages-modules')
Most Node.js internationalization (i18n) libraries today either come with monolithic files to store all localized messages, or they include the concept of "namespaces" to break down messages in smaller files.
But think about it, do we put all CSS in a single file? Or all HTML markup in a single file? Why would it be any different for localized messages.
Ultimately messages are content that can be use in a given context and making it modular optimizes both its management (see proximity principle) while making client bundles size smaller (faster apps!)
FAQs
Messages (localized strings) that are scoped locally.
The npm package messages-modules receives a total of 72 weekly downloads. As such, messages-modules popularity was classified as not popular.
We found that messages-modules 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.