bagoftext

A bag-of-holding containing text utility functions.


Bag Of Text contains text utility functions.

npm install bagoftext

or as a dependency in package.json file:

"dependencies": {
  "bagoftext": "x.y.z"
}
var text = require('bagoftext');

Localisation:

// initialise default locale and the location of locale files
text.initLocales(__dirname, {
  defaultLocale: 'en',
  localesDir: 'path/to/locales/'
});

// display 'Hello Homer Simpson'
console.log(text.__('Hello %s %s', 'Homer', 'Simpson'));

// switch locale to spanish
text.setLocale('es');

// assuming there's a path/to/locales/es.json locale file
// containing { 'Hello %s %s': 'Hola %s %s' }
// then display 'Hola Homer Simpson'
console.log(text.__('Hello %s %s', 'Homer', 'Simpson'));

Developer's Guide

Build reports: