yargs / y18n Goto Github PK
View Code? Open in Web Editor NEW:ledger: the bare-bones i18n library used by yargs
License: ISC License
:ledger: the bare-bones i18n library used by yargs
License: ISC License
We use yargs
and y18n
:
https://github.com/jedmao/eclint/blob/master/lib/cli.ts#L202
When yargs
throw a error by demandCommand(1, 1, i18n('CommandError: Missing required sub-command.'))
yargs
will kill main process. and y18n
not finsh file write.
After executed this steps, any commands dump parse errors.
/usr/local/lib/node_modules/eclint/node_modules/y18n/index.js:79
else throw err
^
SyntaxError: syntax error in /usr/local/lib/node_modules/eclint/locales/ja_JP.json
at JSON.parse (<anonymous>)
Hi,
I am new to dev. This is just a question rather an issue. I noticed that in this commit 3cc0c28, there is engines entry added in package.json file. It indicates that the node version needs to be >=10.0.0. However the command 'npm install y18n' happily installed 5.0.5 with no error or warning on node 8.0.0. Am I missing something obviously? Would you shed me some light on this please.
MacOS: Sierra
Version: 10.12.1
npm version: 6.13.0
Cheers
Sam
Assume a translation:
// locales/xx.json
{
"one %s two %s three": ".... %s ... %s ..."
}
where the order of the args is reversed in the translated string. How do I handle this?
I wrote a static parser for webpack that reads the source files and uses y18n to generate the json file. But cache isn't part of the public api and there is no way to keep readFile from being called in a browser. Is there any way to make this more flexible?
https://github.com/zakkudo/translation-static-analyzer
https://github.com/zakkudo/translate-webpack-plugin
I plan on making npm packages by next week for this, which will be a bit easier to test with....
Would you please create a LICENSE file with the text of the ISC license (and your copyright information) inside? That makes it easier for people like me who package things up for Linux distributions.
When using node <10, it's no longer possible to install y18n@4:
node --version
v8.17.0
yarn add [email protected]
yarn add v1.22.10
[1/4] π Resolving packages...
[2/4] π Fetching packages...
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=10". Got "8.17.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
v4.0.1 works fine:
yarn add [email protected]
yarn add v1.22.10
[1/4] π Resolving packages...
[2/4] π Fetching packages...
[3/4] π Linking dependencies...
[4/4] π¨ Building fresh packages...
Was it an intended change of compatibility?
Team - any plans to release a patch version for 4.0.0 to address below issue
https://snyk.io/vuln/SNYK-JS-Y18N-1021887
Hi there, and thanks for the great package.
I encountered following unexpected behavior.
In the package.json
, the files specified in module
and exports
are mismatched.
exports
, import("y18n")
refers ./index.mjs
of y18n.module
, import("y18n")
refers ./build/lib/index.js
of y18n.{
"exports": {
".": [
{
"import": "./index.mjs",
"require": "./build/index.cjs"
},
"./build/index.cjs"
]
},
"type": "module",
"module": "./build/lib/index.js",
}
As a result, some bundler which doesn't support the exports
field fails to build with yargs as a dependency.
That's because yargs uses the default export of y18n on lib/platform-shims/esm.mjs
,
and ./build/lib/index.js
on y18n doesn't provide the default export.
I created the minimum reproduction in https://github.com/tasshi-playground/repro-y18n-default-export-broken .
$ git clone [email protected]:tasshi-playground/repro-y18n-default-export-broken
$ cd repro-y18n-default-export-broken
$ npm install
$ npm run build
I examined rollup.js and Vite.
rollup supports exports
of package.json, and Vite doesn't support due to the bug of vitejs/vite#11676 .
node_modules/y18n/index.mjs
via exports
.node_modules/y18n/build/lib/index.js
via module
.import y18n from "y18n"
(succeeded)$ npm run build:rollup:import-default-export-of-y18n
> [email protected] build:rollup:import-default-export-of-y18n
> rollup --config ./rollup.config.default-export.mjs
src/importing-default-export.mjs β dist...
created dist in 49ms
import { y18n } from "y18n"
(failed)$ npm run build:rollup:import-named-export-of-y18n
> [email protected] build:rollup:import-named-export-of-y18n
> rollup --config ./rollup.config.named-export.mjs
src/importing-named-export.mjs β dist...
[!] RollupError: "y18n" is not exported by "node_modules/y18n/index.mjs", imported by "src/importing-named-export.mjs".
https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module
src/importing-named-export.mjs (1:9)
1: import { y18n } from "y18n";
^
2:
3: console.log(y18n);
at error (/Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/shared/rollup.js:210:30)
at Module.error (/Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/shared/rollup.js:13578:16)
at Module.traceVariable (/Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/shared/rollup.js:13961:29)
at ModuleScope.findVariable (/Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/shared/rollup.js:12442:39)
at Identifier.bind (/Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/shared/rollup.js:8371:40)
at CallExpression.bind (/Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/shared/rollup.js:6165:28)
at CallExpression.bind (/Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/shared/rollup.js:9888:15)
at ExpressionStatement.bind (/Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/shared/rollup.js:6169:23)
at Program.bind (/Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/shared/rollup.js:6165:28)
at Module.bindReferences (/Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/shared/rollup.js:13574:18)
import y18n from "y18n"
(failed)$ npm run build:vite:import-default-export-of-y18n
> [email protected] build:vite:import-default-export-of-y18n
> vite build --config ./vite.config.default-export.mjs
vite v4.0.4 building for production...
β 2 modules transformed.
"default" is not exported by "node_modules/y18n/build/lib/index.js", imported by "src/importing-default-export.mjs".
file: /Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/src/importing-default-export.mjs:1:7
1: import y18n from "y18n";
^
2:
3: console.log(y18n);
error during build:
RollupError: "default" is not exported by "node_modules/y18n/build/lib/index.js", imported by "src/importing-default-export.mjs".
at error (file:///Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/es/shared/rollup.js:2041:30)
at Module.error (file:///Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/es/shared/rollup.js:13062:16)
at Module.traceVariable (file:///Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/es/shared/rollup.js:13445:29)
at ModuleScope.findVariable (file:///Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/es/shared/rollup.js:11926:39)
at Identifier.bind (file:///Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/es/shared/rollup.js:7855:40)
at CallExpression.bind (file:///Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/es/shared/rollup.js:5649:28)
at CallExpression.bind (file:///Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/es/shared/rollup.js:9372:15)
at ExpressionStatement.bind (file:///Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/es/shared/rollup.js:5653:23)
at Program.bind (file:///Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/es/shared/rollup.js:5649:28)
at Module.bindReferences (file:///Users/tasshi/git/mshrtsr/repro-y18n-default-export-broken/node_modules/rollup/dist/es/shared/rollup.js:13058:18)
import { y18n } from "y18n"
(succeeded)$ npm run build:vite:import-named-export-of-y18n
> [email protected] build:vite:import-named-export-of-y18n
> vite build --config ./vite.config.named-export.mjs
vite v4.0.4 building for production...
β 2 modules transformed.
dist/importing-named-export.vite.cjs 2.84 kB β gzip: 1.10 kB
The file specified in the module
field should be the same as exports
.
{
"exports": {
".": [
{
"import": "./index.mjs",
"require": "./build/index.cjs"
},
"./build/index.cjs"
]
},
"type": "module",
- "module": "./build/lib/index.js",
+ "module": "./index.mjs",
}
I'm not modifying any code, just to keep trying to build on Travis-ci.
About every 10 builds, this error occurs one time.
I have no idea to solve this issue.
Branch | Build failing π¨ |
---|---|
Dependency | mocha |
Current Version | 3.3.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As mocha is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
Mocha is now moving to a quicker release schedule: when non-breaking changes are merged, a release should happen that week.
This week's highlights:
allowUncaught
added to commandline as --allow-uncaught
(and bugfixed)--no-warnings
and --trace-warnings
flags (@sonicdoe)The new version differs by 9 commits0.
7554b31
Add Changelog for v3.4.0
9f7f7ed
Add --trace-warnings
flag
92561c8
Add --no-warnings
flag
ceee976
lint test/integration/fixtures/simple-reporter.js
dcfc094
Revert "use semistandard
directly"
93392dd
no special case for macOS running Karma locally
4d1d91d
--allow-uncaught cli option
fb1e083
fix allowUncaught in browser
4ed3fc5
Add license report and scan status
false
See the full diff
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
The examples are of the form:
var __ = require('y18n').__
console.log(__('my awesome string %s', 'foo'))
But the module returns a constructor function, so the examples should be:
var __ = require('y18n')().__
...
2.6.3
to 2.7.0
.π¨ View failing branch.
This version is covered by your current version range and after updating it in your project the build failed.
rimraf is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
I can't seem to find the 4.0.1
(Prototype Pollution fix), tag anywhere in the repo or in the releases page.
I can see the that there are changes done in the generated output code for the v4.0.1 vs. v4.0.0 and it seems all good :) ππ½
I guess somebody perhaps forgot to push the local changes done and the tag for the v4.x.x branch to the Github Repo here.
I think from a security perspective and keep the history it would be nice to have the changes pushed to the repo here. Otherwise like now some people may wonder if there are actual changes done, or if there is an malicious third party involved (which it's currently not).
Hi, first at all, this is a great & simpler package, it's very useful.
I'm thinking about the use of second/plural argument in __n
function. Making some checks and viewing your tests and implementation, the second argument seems to be meaningless except for keeping it in a file if it doesn't exist. For example:
it('allows an alternative locale to be set', function () {
var __n = y18n({
locale: 'pirate',
directory: path.join(__dirname, 'locales')
}).__n
__n('%d cat', '%d cats', 1).should.equal('1 land catfish')
__n('%d cat', '%d cats', 3).should.equal('3 land catfishes')
})
Here I can write __n('%d cat', 'foo bar', 3)
and still get 3 land catfishes
.
unknown
Perhaps it might be more useful (sometimes at least) to have another method y18n.__p(key, number, ...args)
to use without worrying about updateFiles feature or maybe with a default "unknown" value.
I don't know... It's just a practical suggestion.
Branch | Build failing π¨ |
---|---|
Dependency | coveralls |
Current Version | 3.0.0 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
coveralls is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
Maintenance:
The new version differs by 9 commits.
e7ae2bf
version bump; logger test fix
9b892bf
Verbose use log level debug
9cfb496
Add buildkite support (#177)
aa8c257
Done callback waits for unlink in testRepoTokenDetection to prevent race condition (#179)
18c71c2
Fix a mistype in tests: fs.exists -> fs.existsSync (#184)
bd667c6
Add Semaphore support (#180)
10d8b3e
Update examples to include Jest (#183)
720ee7c
Add license (#175)
83ff2cb
Add mention about AppVeyor to the README (#164)
See the full diff
There is a collection of frequently asked questions. If those donβt help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot π΄
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
These updates are pending. To force PRs open, click the checkbox below.
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
.github/workflows/ci.yaml
actions/checkout v2
actions/setup-node v1
actions/checkout v2
actions/setup-node v1
actions/checkout v2
actions/setup-node v1
actions/checkout v2
actions/setup-node v1
actions/checkout v2
actions/setup-node v1
denolib/setup-deno v2
.github/workflows/release-please.yml
bcoe/release-please-action v3
actions/checkout v2
actions/setup-node v1
actions/setup-node v1
package.json
@rollup/plugin-typescript ^9.0.0
@types/node ^18.0.0
c8 ^7.3.0
chai ^4.0.1
cross-env ^7.0.2
gts ^3.0.0
mocha ^8.0.0
rimraf ^3.0.2
rollup ^2.26.10
standardx ^7.0.0
ts-transform-default-export ^1.0.2
tslib ^2.4.1
typescript ^4.0.0
node >=10
@types/y18n are 5 years old.
I see your project is already in typescript, but you are not exporting *.d.ts
to npm
also in deno.ts you have build/lib/index.d.ts
but by npm this file is missing
Hi,
I'm trying to run your example on https://npm.runkit.com/y18n. I'm getting "TypeError: y18n.__ is not a function". My code is like below.
var y18n = require("y18n")
console.log(y18n.__('%s %s', '1111', '2222'))
I'm a newbie on JS and Nodejs. Can you help me?
const y18n = require('y18n')();
y18n.setLocale('__proto__');
y18n.updateLocale({polluted: true});
console.log(polluted); // true
Index is not built:
/node_modules/y18n/build$ ls
index.cjs lib
Branch | Build failing π¨ |
---|---|
Dependency | coveralls |
Current Version | 2.11.16 |
Type | devDependency |
This version is covered by your current version range and after updating it in your project the build failed.
As coveralls is βonlyβ a devDependency of this project it might not break production or downstream projects, but βonlyβ your build or test tools β preventing new deploys or publishes.
I recommend you give this issue a high priority. Iβm sure you can resolve this πͺ
Adds branch coverage data to Coveralls API post.
There is a collection of frequently asked questions and of course you may always ask my humans.
Your Greenkeeper Bot π΄
Needed for yargs/yargs#1586
The npm package that is published should not include tests.
Background: running into problems in a project I'm working on that uses flow, which fails (understandably) when trying to process invalid JSON files that are in the test
directory of this package.
Simple solution is to add a .npmignore
file containing test
(per npm docs: keeping files out of your package).
Was v4.0.1 an official release? I was looking for it in the changelog and in the tags but do not see it.
Hi folks - y18n
v3.2.2 is published on NPM and there doesn't appear to be a corresponding tagged version in the GitHub repository.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.