Giter Club home page Giter Club logo

y18n's People

Contributors

bcoe avatar gantoine avatar github-actions[bot] avatar greenkeeper[bot] avatar greenkeeperio-bot avatar jameskyburz avatar ljharb avatar luke-john avatar maxrimue avatar nexdrew avatar qmarkc avatar renovate[bot] avatar rivy avatar zkat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

y18n's Issues

Generated empty locales file after `yargs` got an error.

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>)

Is engines entry in package.json working?

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

args order in translations

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?

Make it so that it's easier to load translations dynamically

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....

Create LICENSE file

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.

v.4.0.2 broke compatibility with node 8

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?

The files specified in `module` and `exports` are mismatched.

Hi there, and thanks for the great package.
I encountered following unexpected behavior.

Environment

Summary

In the package.json, the files specified in module and exports are mismatched.

  • Referring exports, import("y18n") refers ./index.mjs of y18n.
  • Referring 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.

Reproduction

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 .

  • rollup refers node_modules/y18n/index.mjs via exports.
  • vite refers node_modules/y18n/build/lib/index.js via module.
Log (click to expand)

rollup.js tried to build the code 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

rollup.js tried to build the code 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)

Vite tried to build the code 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)

Vite tried to build the code 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

Idea

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",
}

An in-range update of mocha is breaking the build 🚨

Version 3.4.0 of mocha just got published.

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 πŸ’ͺ

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v3.4.0

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)
  • warning-related Node flags

πŸŽ‰ Enhancements

πŸ› Fixes

πŸ”© Other

Commits

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

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Examples are wrong

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')().__
...

An in-range update of rimraf is breaking the build 🚨

The devDependency rimraf was updated from 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.

Status Details
  • ❌ continuous-integration/travis-ci/push: The Travis CI build failed (Details).

Commits

The new version differs by 2 commits.

  • 250ee15 2.7.0
  • dc1682d feat: make it possible to omit glob dependency

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Where is the v4.0.1 tag and code changes?

I can't seem to find the 4.0.1 (Prototype Pollution fix), tag anywhere in the repo or in the releases page.

Screenshot 2021-04-06 at 10 25 20

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 :) πŸ‘πŸ½

Screenshot 2021-04-06 at 10 41 33

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).

About __n & plural argument

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.

An in-range update of coveralls is breaking the build 🚨

Version 3.0.1 of coveralls was just published.

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.

Status Details
  • ❌ continuous-integration/travis-ci/push The Travis CI build failed Details
  • βœ… coverage/coveralls First build on greenkeeper/coveralls-3.0.1 at 100.0% Details

Release Notes Additional CI support

Maintenance:

Commits

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

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Other Branches

These updates are pending. To force PRs open, click the checkbox below.

  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update bcoe/release-please-action action to v4

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.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
npm
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

  • Check this box to trigger a request for Renovate to run again on this repository

export Types for typescript & npm

@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

Prototype pollution

POC

const y18n = require('y18n')();
 
y18n.setLocale('__proto__');
y18n.updateLocale({polluted: true});

console.log(polluted); // true

An in-range update of coveralls is breaking the build 🚨

Version 2.12.0 of coveralls just got published.

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 πŸ’ͺ


Status Details
  • βœ… continuous-integration/travis-ci/push The Travis CI build passed Details

  • ❌ coverage/coveralls First build on greenkeeper/coveralls-2.12.0 at 98.63% Details

Release Notes Branch coverage support

Adds branch coverage data to Coveralls API post.

Commits

The new version differs by 2 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

v4.0.1?

Was v4.0.1 an official release? I was looking for it in the changelog and in the tags but do not see it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.