New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-gettext-sprintf

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-gettext-sprintf

A combination of node-gettext and sprintf

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
decreased by-79.41%
Maintainers
1
Weekly downloads
 
Created
Source

#node-gettext-sprintf

A combination of node-gettext and sprintf

Build Status

Installation:

npm install node-gettext-sprintf

Usage:

"use strict";
var fs = require('fs');
var getText = require('node-gettext-sprintf');

// setup the 'test' language
var getText = getText({
	'test': fs.readFileSync('./test.po')
});

/*
Given a PO in this form:

msgid ""
msgstr ""
"Language: test0"
"MIME-Version: 1.0"
"Content-Type: text/plain; charset=UTF-8"
"Content-Transfer-Encoding: 8bit"
"Plural-Forms: nplurals=2; plural=(n != 1);"

msgid "Simple string"
msgstr "Simple string translated"

msgid "1 string, 1 int place-holder: %s, %d"
msgstr "1 string, 1 int place-holder: %s, %d translated"

msgid "Simple string singular"
msgstr[0] "Simple string translated"
msgstr[1] "Simple string translated plural"

msgid "Simple string singular int place-holder: %d"
msgstr[0] "Simple string translated int place-holder: %d"
msgstr[1] "Simple string translated plural int place-holder: %d"

msgctxt "Test Context"
msgid "Simple string in context"
msgstr "Simple string in context translated"

msgctxt "Test Context"
msgid "Simple string singular in context int place-holder: %d"
msgstr[0] "Simple string in context  translated int place-holder: %d"
msgstr[1] "Simple string in context translated plural int place-holder: %d"
*/

// load the 'test' language
languageFns = getText('test');

languageFns.getSingularText("Simple string");
// returns "Simple string translated"

languageFns.getSingularText("1 string, 1 int place-holder: %s, %d", "test-string", 30);
// returns "1 string, 1 int place-holder: test-string, 30 translated"

languageFns.getSingularOrPluralText("Simple string singular", 2);
// returns "Simple string translated plural"

languageFns.getSingularOrPluralText("Simple string singular int place-holder: %d", 2, 20);
// returns "Simple string translated plural int place-holder: 20"

languageFns.getSingularTextInContext("Test Context", "Simple string in context")
// returns "Simple string in context translated"

fns.getSingularOrPluralTextInContext("Test Context", "Simple string singular in context int place-holder: %d", 2, 20),
// returns "Simple string in context translated plural int place-holder: 20"

The following standard gettext methods are also supported:

dgettext (getSingularText)
dpgettext (getSingularTextInContext)
dngettext (getSingularOrPluralText)
dnpgettext (getSingularOrPluralTextInContext)

FAQs

Package last updated on 14 Aug 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc