
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
message-dictionary
Advanced tools
A Simple Message Dictionary Manager for NodeJS (Multi Language)
When we create a Rest API, sometimes we need to standardize the default app messages (ex. the error messages) which is support namespace and internationalization.
$ npm install message-dictionary
const message = require('message-dictionary');
var config = {
dirPath: require('path').join('./locales'), // Required
namespace: 'app'
}
// Load Synchronous
message.init(config).load();
// Or Load Asynchronous
message.init(config).reload();
Note:
dirPath is required.init(object) is to set the configuration.load() is to load locales file data into memory (Synchronous).reload(callback) is to load locales file data into memory (Asynchronous). Callback is optional.console.log(message.list());
// Output
// []
The result output above is [] because you have no any exists data messages.
So let's us create one data. See below.
message.addMessage('EX001','en','Just example data!','',function(err,data) {
if(data.status == true) {
console.log(msg.list());
// output
// [ { code:'EX001', message: { en: 'Just example data!' } } ]
}
});
// or with more information
message.addMessage('EX001','en','Just example data!',{user:'john'},function(err,data) {
if(data.status == true) {
console.log(message.list());
// output
// [ { code:'EX001', message: { en: 'Just example data!' }, user: 'john' } ]
}
});
message.updateMessage('EX001','en','Just update data!','',function(err,data) {
if(data.status == true) {
console.log(message.list());
// output
// [ { code:'EX001', message: { en: 'Just update data!' } } ]
}
});
// or with more information
message.updateMessage('EX001','en','Just update data!',{user:'doe'},function(err,data) {
if(data.status == true) {
console.log(message.list());
// output
// [ { code:'EX001', message: { en: 'Just update data!' }, user:'doe' } ]
}
});
console.log(message.get('EX001', 'en'));
// output
// { code:'EX001', message: 'Just update data!', user:'doe' }
message.deleteMessageLocale('EX001', 'en',function(err,data) {
if(data && data.status == true) {
console.log(message.list());
// output
// if you have only one records and only one locale, then it will return
// [ { code:'EX001', message: {}, user: 'doe' } ]
}
});
message.deleteMessage('EX001',function(err,data) {
if(data && data.status == true) {
console.log(message.list());
// output
// if you have only one records, then it will return []
}
});
For more features, updates and examples, Please see here.
If you want to play around with test
$ npm test
FAQs
A Simple Message Dictionary Manager for NodeJS (Multi Language)
The npm package message-dictionary receives a total of 2 weekly downloads. As such, message-dictionary popularity was classified as not popular.
We found that message-dictionary demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.