UNPKG

poe-i18n

Version:

i18n utility for Path of Exile

17 lines (16 loc) 732 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var formatValues_1 = require("../localize/formatValues"); function printf(text, params, formatters, range_message) { if (formatters === void 0) { formatters = []; } if (range_message === void 0) { range_message = '({min}–{max})'; } var prepared = formatValues_1.formatValues(params, { formatters: formatters, message: range_message }); return prepared .reduce(function (formatted, param, i) { return formatted .replace(new RegExp("%" + (i + 1) + "%", 'g'), String(param)) .replace("%" + (i + 1) + "$+d", "+" + String(param)); }, text) .replace(/%%/g, '%'); } exports.default = printf;