require("js-whatever/js/substitution")(i18n) → {object}
Interpolates placeholders of the form {n} in strings, turning the strings into functions and allowing
arguments to be passed in to hide string concatenation
Parameters:
| Name | Type | Description |
|---|---|---|
i18n |
object | Object containing strings to interpolate |
- Source:
Returns:
A copy of i18n where the strings containing the interpolation pattern have become functions
- Type
- object
Example
var i18n = {
foo: 'Substitution {0}, {1}'
};
var substitutedI18n = substitution(i18n);
substitutedI18n.foo('works', 'like this'); // returns 'Substitution works, like this'
- Source: