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

@bretkikehara/i18n-cli

v1.4.1

Published

i18n command line interface manager

Downloads

14

Readme

i18n CLI

Quickstart: Create Spreadsheet

  1. Install the i18n cli tool.
  • npm install -g @bretkikehara/i18n-cli
  1. Generate a Google console service key.
  2. Enable the Google Sheets or Google Drive APIs.
  3. Create a project config file.
  4. On the command line, generate an uploadable CSV.
  • i18n csv <project>
  1. Create a Google Sheet that will can be shared.
  2. Import the CSV into the Google Sheet.

Now the spreadsheet should be ready to generate bundle files.

Quickstart: Generate Localization Bundles

  1. Ensure the project's sheetname config is the same name as the Google Spreadsheet sheet name.
  2. Ensure config path points to your app's localization directory.
  3. Exec i18n bundles <project> to create the project's localization bundles.
  4. Ensure that the react-i18n module is imported inside your component.
  5. Load you app to see the updates.

Config file

All cli configs can be stored inside a .i18nrc JSON file. The cli will look at the present working directory for the .i18nrc file. This behavior can be overrided by setting the REACT_I18N environment.

$ REACT_I18N=/Users/me/.i18nrc i18n [command]

Basic .i18nrc project

module.exports = (function(env) {
  return {
    "serviceKey": env.I18N_KEY || `${ env.HOME }/.google/service-key-lang.json`,
    "projects": {
      "project1": {
        "spreadsheetId": "google-sheet-id",
        "range": "sheet-name!A1:M1000",
        "output": `${ env.HOME }/project-name2/i18n-directory`,
        "locales": [
          "en-US",
        ],
        "format": "module",
      }
    }
  };
})(process.env);

Example of .i18nrc multi-projects with overrides

module.exports = (function(env) {
  return {
    "serviceKey": env.I18N_KEY || `${ env.HOME }/.google/service-key-lang.json`,
    "spreadsheetId": "google-sheet-id",
    "output": `${ env.HOME }/project-name/i18n-directory`,
    "locales": [
      "en-US",
      "fr-FR"
    ],
    "format": "module",
    "projects": {
     // project that pulls from the global configs.
      "project1": {
        "sheetname": "sheet-name",
        "range": "A1:M1000",
      },
     // project that overrides the global configs.
      "project2": {
        "serviceKey": `${ env.HOME }/.google/override-service-key-lang.json`,
        "spreadsheetId": "override-google-sheet-id",
        "sheetname": "sheet-name-2",
        "output": `${ env.HOME }/project-name2/i18n-directory/override`,
        "locales": [
          "jp-JP",
        ],
        "format": "json",
      }
    }
  };
})(process.env);

Command: bundles

This command will generate the i18n compatible bundle files. Converts the Google sheets rows into a json or es5 module format for you app's consumption.

$ i18n bundles project2

Command: csv

This command will generate a CSV from compatible bundle files. This CSV can be appended to a localization spreadsheet for later consumption using the bundles command.

$ i18n csv project2

Roadmap

  • [x] Create a CSV from existing i18n modules or JSON files
  • [x] Download bundles from Google Sheets
  • [x] Configure CLI using .i18nrc file
  • [x] Configure multiple projects using 1 Google service account.
  • [ ] Import existing i18n modules or JSON files into Google Sheets