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

@panter/transporter

v0.0.10

Published

Sync translations between Airtable and JSON files.

Downloads

414

Readme

TransPorter

Sync translations between Airtable and JSON files.

The currently intended workflow is for doing manual updates via developers, so that the changes are inlcuded in version control. This workflow can be improved (like circumventing a developer's involvement) in future iterations.

Usage

Use npx transporter pull and npx transporter push. The intended workflows are:

Pull

  1. Client updates the translations on Airtable and notifies a dev when they are done.
  2. The dev pulls.

Pull overrides local changes and creates _old file for reference. The changes are to be merged manually and pushed.

Push

  1. A dev adds a feature with new translation keys. They add it to the translations files.
  2. The dev pulls and syncs with changes done on Airtable.
  3. The dev pushes.

Push overrides Airtable changes. Remember to pull before pushing.

Getting started

  1. Create a new base in Airtable. Prepare a new table for Translations with a column for key e.g. Name (it's default, could be change in config) and columns named in locale codes (DE, EN, etc.) for translations.
  2. Create Personal access token with scopes data.records:read, data.records:write in Airtable Developer-hub and ensure that it is in env variable AIRTABLE_API_KEY. Add your base to the token at https://airtable.com/create/tokens.
  3. Create transporter.config.js in the root of your module and fill the config based on the example below.
  4. Run npx transporter pull or npx transporter push

Config

Needs to be filled. Example:

import { Config } from "@panter/transporter";

const config: Config = {
  airtable: {
    baseId: "<ID_HASH>",
    tableId: "<ID_HASH>",
    keyColumName: "Name",
    delimiter: ".",
  },
  langs: ["DE", "EN"],
  sections: [
    {
      transPath: "./public/locales",
      translationName: "common",
      airtable: {
        tableId: "<ID_HASH>",
        keyColumName: "Name",
        delimiter: ".",
      },
    },
    {
      transPath: "./public/locales",
      translationName: "admin",
      airtable: {
        tableId: "<ID_HASH>",
        keyColumName: "Name",
        delimiter: ".",
      },
    },
  ],
};

export default config;
  • keyColumName name for a column with keys for JSON object
  • delimiter is used for flatting JSON objects to key + value pairs. . => (ra.action.save)
  • langs array of locales which is in Airtable
  • sections array LocaleSections
  • LocaleSection: for more separated files for translations
  transPath: string;
  translationName: string;
  includedPrefixes?: string[];
  excludePrefixes?: string[];

Example Airtable base for this config:

Alt text

Airtable URL structure: https://airtable.com/<BASE_ID>/<TABLE_ID>/<VIEW_ID> E.g. https://airtable.com/appmyLk487SgURjgz/tblMtQPWNWCTO1lce/viw2ahFCeyvw6ufpd

CLI

After installing run:

npx transporter

You could use push and pull commands with parameters to overwrite config values.

  -b, --base-id <table-id>   [Optional]  Base id.
  -t, --table-id <table-id>  [Optional]  Table id.
  --view-id <string>         [Optional]  View id.
npx transporter push -t XXXXXX
npx transporter pull -t XXXX -b XXXXX

Outputs

Command pull overwrite your files, if exists create a backup with suffix _old. Also if there are some records without key or value, create log files with these records.

Limits

  1. Free namespaces are limited to 1,2k records. You need to split your records to another base or buy a new plan to increase it. Price tiers: https://airtable.com/pricing
  2. Create/update records is limited 10 per request - could take a while.