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 - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

test/test0Messages.po

2

package.json
{
"name": "node-gettext-sprintf",
"version": "0.0.1",
"version": "0.0.2",
"description": "A combination of node-gettext and sprintf",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -10,3 +10,4 @@ var fs = require('fs');

mfLanguage({
'test': fs.readFileSync(path.join(__dirname, 'messages.po'))
'test0': fs.readFileSync(path.join(__dirname, 'test0Messages.po')),
'test1': fs.readFileSync(path.join(__dirname, 'test1Messages.po'))
}, function(err, res) {

@@ -21,4 +22,4 @@ t.notOk(err, "Did not error on initialize, received: " + util.inspect(err, {depth: null}));

test('Simple strings work', function(t) {
var fns = languageFns('test'); // use languages/test/messages.po
t.equal(fns.getText("Simple string"), "Simple string translated");
var fns = languageFns('test0');
t.equal(fns.getText("test0 - Simple string"), "test0 - Simple string translated");
t.end();

@@ -28,5 +29,5 @@ });

test('sprintf place-holder strings work', function(t) {
var fns = languageFns('test'); // use languages/test/messages.po
t.equal(fns.getText("1 string place-holder: %s", "test-string"), "1 string place-holder: test-string translated");
t.equal(fns.getText("1 string, 1 int place-holder: %s, %d", "test-string", 30), "1 string, 1 int place-holder: test-string, 30 translated");
var fns = languageFns('test0');
t.equal(fns.getText("test0 - 1 string place-holder: %s", "test-string"), "test0 - 1 string place-holder: test-string translated");
t.equal(fns.getText("test0 - 1 string, 1 int place-holder: %s, %d", "test-string", 30), "test0 - 1 string, 1 int place-holder: test-string, 30 translated");
t.end();

@@ -36,4 +37,4 @@ });

test('plural place-holder strings work', function(t) {
var fns = languageFns('test'); // use languages/test/messages.po
t.equal(fns.getPluralText("Simple string singular", 2), "Simple string translated plural");
var fns = languageFns('test0');
t.equal(fns.getPluralText("test0 - Simple string singular", 2), "test0 - Simple string translated plural");
t.end();

@@ -43,5 +44,13 @@ });

test('sprintf plural place-holder strings work', function(t) {
var fns = languageFns('test'); // use languages/test/messages.po
t.equal(fns.getPluralText("Simple string singular int place-holder: %d", 2, 20), "Simple string translated plural int place-holder: 20");
var fns = languageFns('test0');
t.equal(fns.getPluralText("test0 - Simple string singular int place-holder: %d", 2, 20), "test0 - Simple string translated plural int place-holder: 20");
t.end();
});
test('switching language works', function(t) {
var fns0 = languageFns('test0');
t.equal(fns0.getText("test0 - Simple string"), "test0 - Simple string translated");
var fns1 = languageFns('test1');
t.equal(fns1.getText("test1 - Simple string"), "test1 - Simple string translated");
t.end();
});
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