js
Lexicon.Fast and simple storage of your phrases.
Getting started
Example
Lexicon.js brings you ability to resolve message in your vocabulary tree by path. If there no key of path chain, Lexicon tries to resolve the default one.
var vocabulary lexicon; vocabulary = greetings: hi: "Hi, wassup?" hello: "Hello, my dear <%= friend %>!" goodbye: "Goodbye, my dear!" _: "Some greetings to you!" ; lexicon = ; console; // Hi, wassup? console; // Hello, my dear Alf! console; // Some greetings to you!
Options
By default there are few reserved keys:
LexiconDEFAULTS = key: _: '_' info: 'info' error: 'error' ;
But you can redefine them by given options object. For example:
var lexicon = key: _: "_default" ;
Lexicon uses underscore template notation. So if you want to render message dynamically, just declare your message with underscore template syntax, and then pass options to the #getMessage method:
lexicon;
Enjoy =)