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

@betomorrow/sync-wording

v1.2.6

Published

Provide tool to retrieve app wording from Google Sheet and process it to generate i18n json files

Downloads

1,131

Readme

Sync Wording

This tool allow you to manage app's wording with simple Google Sheet file. Just create a sheet with columns for keys and wording. This tool will generate wording files. Your product owner will be able to edit himself apllication's wording

Quick Start

You can find a sample sheet here but it's just a simple sheet with one column for keys and columns for languages like this

| Keys | English | French | | -------------------- | --------- | ------ | | user.firstname_title | Firstname | Prénom | | user.lastname_title | Lastname | Nom |

Integration to your project

  • Install sync-wording as dev dependencies npm install @betomorrow/sync-wording --save-dev
  • Create wording config file named wording_config.json at project root location.
{
  "sheetId": "18Zf_XSU80j_I_VOp9Z4ShdOeUydR6Odyty-ExGBZaz4",
  "output_dir": "src/assets/strings/",
  "languages": {
    "en": {
      "column": "B"
    },
    "fr": {
      "column": "C"
    }
  }
}
  • Add scripts lines to invoke tools easily with npm in package.json
{
  "scripts": {
    "upgrade-wording": "sync-wording --upgrade"
  }
}
  • Then run npm run upgrade-wording

It will ask you to grant access on Google Sheet

> Task :app:downloadWording
Please open the following address in your browser:
  https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.readonly&response_type=code&client_id=1309740887-6u609jvssi5c2e56vd5n5dc4drgsc906.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8181%2Foauth2callback
  • Open url in your browser
  • Grant access

[Authorization Sample]

It will update wording files : ${output_dir}/en.json and ${output_dir}/fr.json

Wording validation

In your google sheet, you can add column indicate that it's a valid translation

| Keys | English | French | Validation | | -------------------- | --------- | ------ | ---------- | | user.firstname_title | Firstname | Prénom | OK | | user.lastname_title | Lastname | Nom | KO |

Then update your configuration file like this

{
  "sheetId": "18Zf_XSU80j_I_VOp9Z4ShdOeUydR6Odyty-ExGBZaz4",
  "output_dir": "src/assets/strings/",
  "validation": {
    "column": "D",
    "expected": "OK"
  },
  "languages": {
    "en": {
      "column": "B"
    },
    "fr": {
      "column": "C"
    }
  }
}

Now the tool will warn you when you update wording containing invalid translations

Options

This tools support 3 options

  • --config : Configuration path
  • --upgrade : Export sheet in local xlsx file that you can commit for later edit. It prevent risks to have unwanted wording changes when you fix bugs. And then update wording
  • --update : Update wording files from local xlsx file
  • --invalid : (error|warning) exist with error when invalid translations found or just warn

Complete Configuration

{
  "credentials": "credentials.json",      // Optional, json google api service credentials, default : use embedded credentials
  "wording_file": "wording.xlsx",         // Optional, local xlsx wording file path

  "sheetId": "THE SHEET ID",              // *Required*
  "shhetNames": ["commons", "app"],       // Optional, default: use all sheets
  "sheetStartIndex": 2,                   // Optional, start row index, default : 2
  "keyColumn": "A",                       // Optional, default : "A"
  "format" : "json",                      // Optional, json output format (json|flat-json|angular-json), default: "json"
  "ignoreEmptyKeys" : false               // Optional, whether or not empty keys should be kept, default: false
  "validation" : {                        // Optional, global configuration to validate wording
    "column" : "E"
    "expected" : "OK"
  }
  "output_dir": "src/assets/strings/",
  "languages": {
    "en": {
      "output": "src/assets/strings/default.json",  // Optional, default: "${output_dir}/${language_name}.json"
      "column": "B",
      "validation" : {                        // Optional, local configuration to validate wording
        "column" : "E"
        "expected" : "OK"
      }
    },
    "fr": {
      "output": "src/assets/strings/fr.json",
      "column": "C"
    }
    // [...] Add more languages here
  }
}

Note

This tool includes Google Projet credentials for convenience use but you can setup your own projet. Create new project in GCP Console then enable Drive API in API library and create and download credentials.

Development

Current repository use this Sheet : https://docs.google.com/spreadsheets/d/18Zf_XSU80j_I_VOp9Z4ShdOeUydR6Odyty-ExGBZaz4/edit#gid=0

Build and install locally

npm run build
npm run installPackage

Run

rm  .google_*
sync-wording --upgrade

Publish

npm login
npm publish