Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A bag-of-holding containing text utility functions
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test-integration
test
.bob.json
.gitignore
.npmignore
.travis.yml
CHANGELOG.md
LICENSE
README.md
avatar.jpg
package.json

README.md

Avatar

Build Status Dependencies Status Coverage Status Published Version
npm Badge

Bag Of Text

Bag Of Text contains text utility functions.

Installation

npm install bagoftext

or as a dependency in package.json file:

"dependencies": {
  "bagoftext": "x.y.z"
}

Usage

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'));

Colophon

Developer's Guide

Build reports:

Something went wrong with that request. Please try again.