This is a simple library which stores language strings, and allows retrieval with interpolation.
simply npm install the repo or add it to your package.json
import { Messages, localizeFilterFactory } from 'lst-messages';
const messageJson = require(LOCALE_SRC);
const messages = new Messages(messageJson);
angular.module('lwcLocalize', [])
.filter('i18n', () => localizeFilterFactory(messages));
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' }