Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

i18n-core

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-core - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

11

lib/createTranslator.js

@@ -47,3 +47,3 @@ "use strict";

count = plural;
plural = singular;
plural = typeof singular === "object" ? singular : null;
startOfArgs -= 1;

@@ -62,3 +62,3 @@ }

singular.one)
: singular);
: null);
}

@@ -76,4 +76,7 @@ if (typeof singular === "object") {

if (count > 1) {
keys = [plural, singular + "." + count, singular + ".other", singular, singular + ".one"];
fallbackKey = plural;
keys = [singular + "." + count, singular + ".other", singular, singular + ".one"];
if (plural) {
keys.unshift(plural)
}
fallbackKey = plural || singular;
} else {

@@ -80,0 +83,0 @@ keys = [singular + ".one", singular];

{
"name": "i18n-core",
"version": "1.3.1",
"version": "1.3.2",
"description": "Basic i18n translation.",

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

},
"repository" : {
"type" : "git",
"url" : "git@github.com:martinheidegger/i18n-core.git"
"repository": {
"type": "git",
"url": "git@github.com:martinheidegger/i18n-core.git"
},

@@ -26,0 +26,0 @@ "devDependencies": {

@@ -244,3 +244,41 @@ "use strict";

test("plural special fallbacks", function (done) {
var translator = i18n({a: "b", c: {one: "d", other: "e"}}),
__n = translator.__n;
expect(__n("a", 2)).to.equal("b");
expect(__n("c", 2)).to.equal("e");
expect(__n("g", {other: "f"}, 2)).to.equal("f");
done();
});
test("sprintf strings to be treated as strings", function (done) {
var __ = i18n().__;
expect(__('%s', 1)).to.equal("1");
expect(__('%s', "01")).to.equal("01");
expect(__('%s', false)).to.equal("false");
expect(__('%s', "false")).to.equal("false");
expect(__('%s', true)).to.equal("true");
expect(__('%s', "true")).to.equal("true");
expect(__('%s', null)).to.equal("null");
expect(__('%s', "null")).to.equal("null");
expect(__('%s', undefined)).to.equal("undefined");
expect(__('%s', "undefined")).to.equal("undefined");
done();
});
test("mustach strings to be treated as strings", function (done) {
var __ = i18n({"$": "{{data}}"}).__;
expect(__('$', {data: 1})).to.equal("1");
expect(__('$', {data: "01"})).to.equal("01");
expect(__('$', {data: false})).to.equal("false");
expect(__('$', {data: "false"})).to.equal("false");
expect(__('$', {data: true})).to.equal("true");
expect(__('$', {data: "true"})).to.equal("true");
expect(__('$', {data: null})).to.equal("");
expect(__('$', {data: "null"})).to.equal("null");
expect(__('$', {data: undefined})).to.equal("");
expect(__('$', {data: "undefined"})).to.equal("undefined");
done();
});
test("same translator", function (done) {

@@ -247,0 +285,0 @@ var set = i18n();

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