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

sheetspeare

v0.7.4

Published

Import locales from Google Sheet into Json files.

Downloads

6

Readme

Sheetspeare - Google Spreadsheet Translation Loader CLI

npm version

Sheetspeare is a powerful CLI tool that allows you to manage translations for your application using Google Spreadsheets. It simplifies the process of loading translation files from a Google Spreadsheet and keeping them in sync with your codebase. Say goodbye to manual copy-pasting and tedious translation management!

Installation

Install the package using npm:

npm install --save-dev sheetspeare

Setup

To start using Sheetspeare, follow these steps:

Setup a Google project:

  1. Go to the Google Developers Console
  2. Select your project or create a new one (and then select it)
  3. Enable the Sheets API for your project
  4. In the sidebar on the left, select Enabled APIs & Services
  5. Click the blue "Enable APIs and Services" button in the top bar
  6. Search for "sheets"
  7. Click on "Google Sheets API"
  8. click the blue "Enable" button

Create a Google Service Account:

  1. In the sidebar on the left, select APIs & Services > Credentials
  2. Click blue "+ CREATE CREDENTIALS" and select "Service account" option
  3. Enter name, description, click "CREATE"
  4. You can skip permissions, click "CONTINUE"
  5. Click "+ CREATE KEY" button
  6. Select the "JSON" key type option
  7. Click "Create" button
  8. your JSON key file is generated and downloaded to your machine (it is the only copy!) Keep it in a safe place. we will use it the following steps.
  9. click "DONE"
  10. note your service account's email address (also available in the JSON key file)

For more details on how to setup the Google Service Account and Project visit the authentication section of the google-spreadsheet package documentation

Create a Google Spreadsheet:

Create a new Google Spreadsheet and share it with your service account using the email noted above. Note the Google Spreadsheet id from the URL https://docs.google.com/spreadsheets/d/{spreadsheetId}/edit.... It is needed in the following steps.

Setup Environment Variables:

From the downloaded JSON key file, set the following environment variables:

SERVICE_ACCOUNT_EMAIL="client_email" SERVICE_ACCOUNT_PRIVATE_KEY="private_key"

Or add them to your dotenv file:

# .env
SERVICE_ACCOUNT_EMAIL="client_email"
SERVICE_ACCOUNT_PRIVATE_KEY="private_key"

Initialize the project:

Run the following command to initialize the project:

npx sheetspeare init

A .sheetspearerc.json config file will be added which stores the configuration for the project.

Usage

The Sheetspeare CLI offers the following commands:

  1. init: Initialize the Google Spreadsheet connection and create a configuration file.

  2. pull: Pull translations from the Google Spreadsheet and update the locale files in your project.

  3. push: Push updated translations from your project's locale files back to the Google Spreadsheet.

  4. help: Show the help menu and available commands.

Configuration

After running the init command, Sheetspeare will create a configuration file named .sheetspearerc.json in your project's root directory. You can manually edit this file if you need to change the default settings.

{
  "locales": ["en", "es", ...],
  "spreadsheetId": "...",
  "path": "src/locales"
}
  • spreadsheetId: The ID of the Google Spreadsheet containing the translations.
  • path: The path to the directory containing the locale files.
  • locales: An array of locale codes to pull from the Google Spreadsheet. The locale files under the path directory will be named using these locale codes.

Note: This CLI is supports cosmiconfig config formats. You may move the configuration to other supported formats such as .sheetspearerc.js or even to your package.json file under sheetspeare property and it will be loaded automatically.

Contributing

We welcome contributions to Sheetspeare! If you find any bugs, have suggestions for improvements, or want to add new features, feel free to open an issue or submit a pull request on GitHub: GitHub Repository

License

This project is licensed under the MIT License - see the LICENSE file for details.