Comparing version 3.2.1 to 4.0.0
16
index.js
@@ -19,2 +19,5 @@ var fs = require('fs') | ||
Y18N.prototype.__ = function () { | ||
if (typeof arguments[0] !== 'string') { | ||
return this._taggedLiteral.apply(this, arguments) | ||
} | ||
var args = Array.prototype.slice.call(arguments) | ||
@@ -44,2 +47,15 @@ var str = args.shift() | ||
Y18N.prototype._taggedLiteral = function (parts) { | ||
var args = arguments | ||
var str = '' | ||
parts.forEach(function (part, i) { | ||
var arg = args[i + 1] | ||
str += part | ||
if (typeof arg !== 'undefined') { | ||
str += '%s' | ||
} | ||
}) | ||
return this.__.apply(null, [str].concat([].slice.call(arguments, 1))) | ||
} | ||
Y18N.prototype._enqueueWrite = function (work) { | ||
@@ -46,0 +62,0 @@ this.writeQueue.push(work) |
{ | ||
"name": "y18n", | ||
"version": "3.2.1", | ||
"version": "4.0.0", | ||
"description": "the bare-bones internationalization library used by yargs", | ||
@@ -9,3 +9,4 @@ "main": "index.js", | ||
"test": "nyc mocha", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls" | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"release": "standard-version" | ||
}, | ||
@@ -31,9 +32,10 @@ "repository": { | ||
"devDependencies": { | ||
"chai": "^3.4.1", | ||
"coveralls": "^2.11.6", | ||
"mocha": "^2.3.4", | ||
"nyc": "^6.1.1", | ||
"chai": "^4.0.1", | ||
"coveralls": "^3.0.0", | ||
"mocha": "^4.0.1", | ||
"nyc": "^11.0.1", | ||
"rimraf": "^2.5.0", | ||
"standard": "^5.4.1" | ||
"standard": "^10.0.0-beta.0", | ||
"standard-version": "^4.2.0" | ||
} | ||
} |
@@ -7,2 +7,3 @@ # y18n | ||
[![js-standard-style][standard-image]][standard-url] | ||
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org) | ||
@@ -27,2 +28,15 @@ The bare-bones internationalization library used by yargs. | ||
_using tagged template literals_ | ||
```js | ||
var __ = require('y18n').__ | ||
var str = 'foo' | ||
console.log(__`my awesome string ${str}`) | ||
``` | ||
output: | ||
`my awesome string foo` | ||
_pluralization support:_ | ||
@@ -65,2 +79,6 @@ | ||
This function can also be used as a tag for a template literal. You can use it | ||
like this: <code>__`hello ${'world'}`</code>. This will be equivalent to | ||
`__('hello %s', 'world')`. | ||
### y18n.\_\_n(singularString, pluralString, count, arg, arg, arg) | ||
@@ -67,0 +85,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10437
5
153
110
7