# airtable-i18n

> A CLI to generate i18n translations from airtable.

Latest version **1.1.7** (published 2021-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install airtable-i18n
pnpm add airtable-i18n
yarn add airtable-i18n
bun add airtable-i18n
```

Provides the command `airtable-i18n`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.7 |
| Published | 2021-05-29 |
| First published | 2021-02-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Balázs Szalay |
| Maintainers | szalaybalazs |
| Keywords | i18n, airtable, translation |

## Links

- npm: https://www.npmjs.com/package/airtable-i18n
- Repository: https://github.com/szalaybalazs/airtable-i18n
- Homepage: https://github.com/szalaybalazs/airtable-i18n#readme
- Issues: https://github.com/szalaybalazs/airtable-i18n/issues
- npm.io page: https://npm.io/package/airtable-i18n

## Dependencies (4)

- [chalk](https://npm.io/package/chalk.md) ^4.1.0
- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [airtable](https://npm.io/package/airtable.md) ^0.10.1
- [commander](https://npm.io/package/commander.md) ^7.0.0

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 1.1.7 (latest) — 2021-05-29
- 1.1.6 — 2021-02-10
- 1.1.5 — 2021-02-10
- 1.1.4 — 2021-02-10
- 1.1.3 — 2021-02-10
- 1.1.2 — 2021-02-10
- 1.1.1 — 2021-02-10
- 1.0.9 — 2021-02-09
- 1.0.8 — 2021-02-09
- 1.0.7 — 2021-02-09
- 1.0.5 — 2021-02-09
- 1.0.4 — 2021-02-09
- 1.0.3 — 2021-02-09
- 1.0.2 — 2021-02-09
- 1.0.1 — 2021-02-09
- … 1 more at https://npm.io/package/airtable-i18n/versions

## README

Generate i18n translations from airtable base.
===

Generate separate translation files from airtable base.

Usage
---

1. Retreive Airtable api key

    Visit [Airtable Account page](https://airtable.com/account) and generate an api key.

2. Get the ID of translation base
    
    Visit [Airtable interactive API](https://airtable.com/api) and copy your translation base's ID.

3. Configure your base
  
    1. Create a `Lng` table in the base, with fields: `key | lng1 | lng2`

    2. Create a `TABLES` table with only one column, `name`, containing the name all the translation tables, except the `Lng` table.

    3. Create your first translation table.

### Example

**Lng**

| key | en | de | es |
|:---:|:--:|:--:|:--:|
|Key|EN|DE|ES|
|Name|English|German|Spanish|

**TABLES**

|name|
|:--:|
|general|

**general**

| key | en | de | es |
|:---:|:--:|:--:|:--:|
|Title|Demo translation|Demo-Übersetzung|Traducción de demostración|

### Example usage

Automatise the CLI command to run before each commit to generate translations each time when a commit is submited.

## CLI

`npx airtable-i18n`

### Options
```bash
-a, --api <apikey> - Airtable APIKEY
-t, --base <baseid> - ID of the airtable base
-d, --directory <directory> - Output directory of translations - OPTIONAL - Default: the same directory
-b, --beautify - Whether to beautify the generated language files
-f, --format - Format used to output the translations to
-e, --env <path> - relative path to .env file - OPTIONAL - Default: the same directory
-i, --index - provide flag to create an index.js file with all the exports
```

By default the command will search for an .env file in the same directory.

### .env options
```dotenv
AIRTABLE_I18N_DIRECTORY=<directory> - Example: .
AIRTABLE_I18N_API_KEY=<APIKEY>
AIRTABLE_I18N_BASE_ID=<BASEID>
AIRTABLE_I18N_TRANSLATION_FORMAT=<FILEFORMAT> - either js or json
AIRTABLE_I18N_INDEX=any - provide to generate index.js file with all the exports
```

### Example usage

```bash
npx airtable-i18n -a <APIKEY> -b <BASEID> -d ./translation -b -f json
```

or

```bash
npm i -g airtable-i18n
airtable-i18n -a <APIKEY> -b <BASEID> -d ./translation -b -f json
```

## Node package
```javascript
const { generateTranslation } = require('./index');

generateTranslation('<APIKEY>', '<BASEID>', { output: './lngs', beutify: true, format: 'js' });
```

### Options

| Option | Required | Description | Default |
|--------|:--------:|-------------|---------|
| APIKEY | True | The airtable apikey | - |
| BASEID | True | The ID of the airtable base | - |
| output | false | The output directory for translations | '.' |
| beautify | false | Whether to beautify the generated translation files | false |
| format | false | The format of the output files | js |
| generateIndex | false | Whether to generate index.js file | false |

## Access translation

The translations are grouped under the name of the tables. 

The key value of the record is used as the key of the translation.

### Example using react

```js
const { t } = useTranslation('<TABLE_NAME>');
t('<TRANSLATION_KEY>);
```

---
_Source: https://npm.io/package/airtable-i18n · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
