daniel-nemeth/subplur

Substitute & Pluralize for JavaScript and jQuery

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Type:contao-component

1.0.0 2018-12-29 14:51 UTC

This package is not auto-updated.

Last update: 2024-04-28 22:53:47 UTC


README

Substitute & Pluralize for JavaScript and jQuery. This is an contao-component.

Usage

var subplur = new dnSubPlur();

// Substitute
var string = 'This is an [example] for substitute.';
subplur.substitute(string, {example: 'test'}); // or with jQuery
$.substitute(string, {example: 'test'});

// Pluralize
var string = 'There {are|is} [num] apple{s} on the tree.';
subplur.pluralize(string, 1); // There is 1 apple on the tree.
$.pluralize(string, 1);

subplur.pluralize(string, 3); // There are 3 apples on the tree.
$.pluralize(string, 3);

// Substitute & Pluralize
var string = 'There {are|is} [num] [apple]{s} on the tree.';
subplur.subplur(string, 1, {apple: 'banana'}); // There is 1 banana on the tree.
$.subplur(string, 1, {apple: 'banana'});

subplur.subplur(string, 3, {apple: 'banana'}); // There are 3 bananas on the tree.
$.subplur(string, 3, {apple: 'banana'});