How to use the sprintf-js.vsprintf function in sprintf-js

To help you get started, we’ve selected a few sprintf-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github TrigenSoftware / i18n-for-browser / src / index.js View on Github external
function postProcess(_text, namedValues, params, count) {

	let text = _text;

	// test for parsable interval string
	if (/\|/.test(text)) {
		text = parsePluralInterval(text, count);
	}

	// replace the counter
	if (typeof count == 'number') {
		text = vsprintf(text, [parseInt(count, 10)]);
	}

	// if the text string contains {{Mustache}} patterns we render it as a mini tempalate
	if (/\{\{.*\}\}/.test(text)) {
		text = Mustache.render(text, namedValues);
	}

	// if we have extra arguments with values to get replaced,
	// an additional substition injects those strings afterwards
	if (/%/.test(text) && params.length) {
		text = vsprintf(text, params);
	}

	return text;
}
github TrigenSoftware / i18n-for-browser / src / index.js View on Github external
}

	// replace the counter
	if (typeof count == 'number') {
		text = vsprintf(text, [parseInt(count, 10)]);
	}

	// if the text string contains {{Mustache}} patterns we render it as a mini tempalate
	if (/\{\{.*\}\}/.test(text)) {
		text = Mustache.render(text, namedValues);
	}

	// if we have extra arguments with values to get replaced,
	// an additional substition injects those strings afterwards
	if (/%/.test(text) && params.length) {
		text = vsprintf(text, params);
	}

	return text;
}
github mashpie / i18n-node / i18n.js View on Github external
var postProcess = function(msg, namedValues, args, count) {

    // test for parsable interval string
    if ((/\|/).test(msg)) {
      msg = parsePluralInterval(msg, count);
    }

    // replace the counter
    if (typeof count === 'number') {
      msg = vsprintf(msg, [parseInt(count, 10)]);
    }

    // if the msg string contains {{Mustache}} patterns we render it as a mini tempalate
    if ((/{{.*}}/).test(msg)) {
      msg = Mustache.render(msg, namedValues);
    }

    // if we have extra arguments with values to get replaced,
    // an additional substition injects those strings afterwards
    if ((/%/).test(msg) && args && args.length > 0) {
      msg = vsprintf(msg, args);
    }

    return msg;
  };
github angular / angular / tools / benchpress / src / reporter.es6 View on Github external
function printRow(format, values) {
  console.log(vsprintf(format, values));
}
github taobataoma / meanTorrent / config / lib / mtRSS.js View on Github external
res.writeHead(200, {
    'Content-Type': 'text/xml'
  });

  res.write('');
  res.write('');
  res.write('');

  var title = vsprintf(rssConfig.title, [appConfig.name + ' - ' + stype]);
  var link = appConfig.domain;
  var desc = vsprintf(rssConfig.description, [appConfig.name]);
  var lang = language;
  var copy = vsprintf(rssConfig.copyright, [appConfig.name]);
  var editor = vsprintf(rssConfig.managingEditor, [appConfig.name]);
  var master = vsprintf(rssConfig.webMaster, [appConfig.name]);
  var lastBuild = moment().toString();
  var gen = rssConfig.generator;
  var docs = 'http://www.rssboard.org/rss-specification';
  var ttl = rssConfig.ttl;
  var img = {
    title: title,
    link: link,
    desc: desc,
    url: appConfig.domain + '/modules/core/client/img/rss.jpeg'
  };

  res.write('<title>' + getEscapeData(title) + '</title>');
  res.write('' + getEscapeData(link) + '');
  res.write('' + getEscapeData(desc) + '');
  res.write('' + getEscapeData(lang, false) + '');
  res.write('' + getEscapeData(copy) + '');
github microsoft / BotBuilder-V3 / Node / core / lib / Message.js View on Github external
function fmtText(session, prompts, args) {
    var fmt = Message.randomPrompt(prompts);
    if (session) {
        fmt = session.gettext(fmt);
    }
    return args && args.length > 0 ? sprintf.vsprintf(fmt, args) : fmt;
}
exports.fmtText = fmtText;
github taobataoma / meanTorrent / modules / torrents / server / controllers / torrents.server.controller.js View on Github external
function announceTorrentToIRC(torrent, req) {
  //irc announce
  if (ircConfig.enable) {
    var msg = '';
    var client = req.app.get('ircClient');

    if (torrent.torrent_type === 'tvserial') {
      msg = vsprintf(ircConfig.tvserialMsgFormat, [
        torrent.user.displayName,
        torrent.torrent_filename,
        torrent.torrent_type,
        torrent.torrent_size,
        torrent.torrent_seasons,
        torrent.torrent_episodes,
        torrent.torrent_sale_status,
        appConfig.domain + '/api/torrents/download/' + torrent._id,
        moment().format('YYYY-MM-DD HH:mm:ss')
      ]);
    } else {
      msg = vsprintf(ircConfig.defaultMsgFormat, [
        torrent.user.displayName,
        torrent.torrent_filename,
        torrent.torrent_type,
        torrent.torrent_size,
github taobataoma / meanTorrent / modules / torrents / server / controllers / torrents.server.controller.js View on Github external
var client = req.app.get('ircClient');

    if (torrent.torrent_type === 'tvserial') {
      msg = vsprintf(ircConfig.tvserialMsgFormat, [
        torrent.user.displayName,
        torrent.torrent_filename,
        torrent.torrent_type,
        torrent.torrent_size,
        torrent.torrent_seasons,
        torrent.torrent_episodes,
        torrent.torrent_sale_status,
        appConfig.domain + '/api/torrents/download/' + torrent._id,
        moment().format('YYYY-MM-DD HH:mm:ss')
      ]);
    } else {
      msg = vsprintf(ircConfig.defaultMsgFormat, [
        torrent.user.displayName,
        torrent.torrent_filename,
        torrent.torrent_type,
        torrent.torrent_size,
        torrent.torrent_sale_status,
        appConfig.domain + '/api/torrents/download/' + torrent._id,
        moment().format('YYYY-MM-DD HH:mm:ss')
      ]);
    }
    client.notice(ircConfig.channel, msg);
  }
}
github microsoft / botbuilder-js / libraries / botbuilder-legacy / lib / Message.js View on Github external
Message.composePrompt = function (session, prompts, args) {
        var connector = '';
        var prompt = '';
        for (var i = 0; i &lt; prompts.length; i++) {
            var txt = Message.randomPrompt(prompts[i]);
            prompt += connector + (session ? session.gettext(txt) : txt);
            connector = ' ';
        }
        return args &amp;&amp; args.length &gt; 0 ? sprintf.vsprintf(prompt, args) : prompt;
    };
    //-------------------

sprintf-js

JavaScript sprintf implementation

BSD-3-Clause
Latest version published 8 months ago

Package Health Score

76 / 100
Full package analysis

Similar packages