lst-messages
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

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' }

Package Sidebar

Install

npm i lst-messages

Weekly Downloads

1

Version

0.0.5

License

FOR INTERNAL USE ONLY

Unpacked Size

93.7 kB

Total Files

17

Last publish

Collaborators

  • ujosedi