message-dictionary
A Simple Message Dictionary Manager for NodeJS (Multi Language)
Background
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.
Install using NPM
$ npm install message-dictionary
Usage
const message = ; var config = dirPath: // Required namespace: 'app' // Load Synchronousmessage; // Or Load Asynchronousmessage;
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 isoptional
.- This library is working like singleton. Once this called, this will shared globally, so you don't need to always load and re-init.
Get List
console; // Output// []
The result output above is []
because you have no any exists data messages.
So let's us create one data. See below.
Add Message
message; // or with more informationmessage;
Update Message
message; // or with more informationmessage;
Get Message
console; // output// { code:'EX001', message: 'Just update data!', user:'doe' }
Delete Message Locale
message;
Delete Message
message;
Documentation
For more features, updates and examples, Please see here.
Unit Test
If you want to play around with test
$ npm test