lst-messages
v0.0.5
Published
Simple messages service for localization purposes
Downloads
3
Readme
LST Messages
A string utility for localization
This is a simple library which stores language strings, and allows retrieval with interpolation.
Installation
simply npm install the repo or add it to your package.json
Usage
Angular with imported json
import { Messages, localizeFilterFactory } from 'lst-messages';
const messageJson = require(LOCALE_SRC);
const messages = new Messages(messageJson);
angular.module('lwcLocalize', [])
.filter('i18n', () => localizeFilterFactory(messages));
Inline
const messages = new Messages({
homePage: {
heading: 'Welcome {0}',
buttons: {
action: 'Buy Now'
}
}
});
const localizeFilter = localizeFilterFactory(messages);
localizeFilter('homePage.heading', ['Joe']); // returns 'Welcome Joe'
localizeFilter('homePage.buttons', undefined, true); // returns { action: 'Buy Now' }