0.6.0 • Published 1 month ago

@febase/i18n-spreadsheet v0.6.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

i18n translation vendor cli tool

Pipeline

Note: This section is taken from formatjs - Application Workflow

i18n translation pipeline

1. Extraction: This step aggregates all messages from your application into a single JSON file along with description, ready to be translated.

2. Upload Messages: This step uploads the JSON file to your translation vendor.

3. Download Translations: This step either polls your translation vendor or hook into your vendor to download translated messages in the set of locales that you configured.

4. Commit: This commits back translation messages to the codebase.

Note: This tool only supports step 2 and 3.

Required

System

  • Nodejs version: >=16

Authentication

Create a service account that connect as a bot user that belongs to your app.

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

  • Menu sidebar -> APIs & services
  • Click the blue Enable APIs and Services button in the top bar
  • Search for sheets
  • Click on Google Sheets API
  • Click the blue Enable button

4. Enable the Google Drive API for your project

  • Menu sidebar -> APIs & services
  • Click the blue Enable APIs and Services button in the top bar
  • Search for Google Drive API
  • Click on Google Sheets API
  • Click the blue Enable button

5. Create a service account for your project

  • Menu sidebar -> APIs & services -> Credentials
  • Click blue + CREATE CREDENTIALS button in the top bar and select Service account option
  • Enter name, description
  • You can skip step 2 Grant this service account access to project and step 3 Grant users access to this service account
  • Click DONE button
  • Select the created service account
  • Select the KEYS tab in the top bar
  • Select ADD KEY dropdown
  • Select Create new key option
  • Select the Key type json
  • Click CREATE button
  • Download the credentials file and save it in your computer.

Note: Be careful - never check your API keys / secrets into version control (git)

Installation

  • pnpm
pnpm add -D @febase/i18n-spreadsheet

## CLI

Add the following command to your package.json scripts:

```json
{
  "scripts": {
    "upload": "i18n-spreadsheet upload --config=<config-path>",
    "download": "i18n-spreadsheet download --config=<config-path>",
    "clear": "i18n-spreadsheet delete --config=<config-path>"
  }
}

Required option --config <path>

To run the commands you need to provide a config file using the --config <path> option.

Config file

{
  "$schema": "../node_modules/@febase/i18n-spreadsheet/config.schema.json",
  "credentials": "./creds.json",
  "fileType": "xliff12", // "json" | "xliff12"
  "inputFiles": "./xliff/*.xlf", // or ./json/*.json -> glob files
  "output": "./build/xliff", // output folder
  "sourceLocale": "en", // default locale
  "targetLocales": ["ja", "ko", "zh"], // rest locales
  "spreadsheetID": "1_BOT1GBBGdliWDSlK8eBtGDB1JcI5uLpzutHmdfN73g", // Google Spreadsheet ID
  "tab": 0,
  "hasDescription": true, // true: create Description column in gg sheet
  "messageFormater": 'string' | {
    "message": "defaultMessage", // default: message
    "description": "description",  // default: description
  }
}

Note and Tips

Note

  • This tool uses google spreadsheet to make i18n translation vendor using googleapis npm packages.

Tips

1. Put your the credentials file to .gitignore file.

2. Create a new spreadsheet manually on your google account and share it to the service account's email with the access permission as editor.

  • This makes it easy to manage the spreadsheet using the UI.
  • You can fully control it with owner access permission.

3. Credentials file can be used for many different projects in your company

0.6.0

1 month ago

0.5.0

2 months ago

0.4.0

3 months ago

0.3.4

5 months ago

0.3.3

5 months ago

0.3.2

5 months ago

0.3.1

6 months ago

0.3.0

6 months ago

0.2.0

6 months ago

0.1.5

6 months ago

0.1.4

6 months ago

0.1.3

7 months ago

0.1.2

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago