npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

yc-i18n-transformers

v2.0.1

Published

Transform source code related to [`i18n`](https://github.com/yandex-cloud/i18n) staff. During transforming process, keysets with translations will be emitted. No more manual manipulation with `.json` files

Downloads

18

Readme

yc-i18n-transformers

Transform source code related to i18n staff. During transforming process, keysets with translations will be emitted. No more manual manipulation with .json files

Prerequisites:

  • you know that node.js is and have one installed

Tool description and options:

npx yc-i18n-transformers --help

Usage:

  • for example, during development process you have received the following code:

    // src/Button.tsx
    
    // this import needed to understand where the import of i18n functions should be from
    // I18NCODEMOD - implementation of this function is at your discretion
    import { I18NCODEMOD } from "~/utils/i18n";
    
    const Button = () => (
      <Button>
        {I18NCODEMOD("example.keyset", "parrot", "Попугай", "Parrot")}
      </Button>
    );

    You can also omit the first argument (keyset name) and bind the keyset name from the -b (bind) option.

    // assume that kayset name come from cli args
    const Button = () => (
      <Button>{I18NCODEMOD("parrot", "Попугай", "Parrot")}</Button>
    );
    npx yc-i18n-transformers -s ui -n I18NCODEMOD -b 'zoo'
  • in you project root directory run command:

    npx yc-i18n-transformers -s src -n I18NCODEMOD -p "i18n@<keyset>"
  • source files will be formatted into this code:

    // src/Button.tsx
    import i18n from "~/utils/i18n";
    
    const Button = () => <Button>{i18n("example.keyset", "parrot")}</Button>;
  • and files with keysets will be emitted near the transformed file

        src
        │   Button.tsx
    +   └───[email protected]
    +       │   ru.json
    +       │   en.json
    +       │   keyset.json
    +       │   context.json

    Use -k option to emit/edit keysets on one dir: npx yc-i18n-transformers -s src/ui -n I18NCODEMOD -k "src/i18n-keysets"

        src
        └───ui
        │   │   Button.tsx
    +   └───i18n-keysets
    +       └───example.keyset
    +           │   ru.json
    +           │   en.json
    +           │   keyset.json
    +           │   context.json

Quick try

git clone https://github.com/IsaevAlexandr/yc-i18n-transformers.git
cd yc-i18n-transformers/examples/singleKeysetDir
npx yc-i18n-transformers -s ui -k i18n/keysets -n i18nCODEMODE

development

npm i
# for local development try this commands
npm run dev --  -s examples/singleKeysetDir -n i18nPartial -b foo.bar -k examples/singleKeysetDir/i18n-keysets
npm run dev --  -s examples/singleKeysetDir -n i18nCODEMODE -k examples/singleKeysetDir/i18n-keysets
npm run dev --  -s examples/singleKeysetDir -n i18nCODEMODE -p "i18n@<keyset>"
npm run dev --  -s examples/singleKeysetDir -n i18nCODEMODE -k examples/singleKeysetDir/i18n-keysets --include js

npm run dev --  -s examples/tsFormatter -n i18nPartial -b foo.bar -k examples/tsFormatter/i18n-keysets -f json
npm run dev --  -s examples/tsFormatter -n i18nCODEMODE -k examples/tsFormatter/i18n-keysets --format json
npm run dev --  -s examples/tsFormatter -n i18nCODEMODE -p "i18n@<keyset>" --format json
npm run dev --  -s examples/tsFormatter -n i18nCODEMODE -k examples/tsFormatter/i18n-keysets -i js -f json