1.1.7 • Published 3 years ago

airtable-i18n v1.1.7

Weekly downloads
45
License
MIT
Repository
github
Last release
3 years ago

Generate i18n translations from airtable base.

Generate separate translation files from airtable base.

Usage

  1. Retreive Airtable api key

    Visit Airtable Account page and generate an api key.

  2. Get the ID of translation base

    Visit Airtable interactive 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

keyendees
KeyENDEES
NameEnglishGermanSpanish

TABLES

name
general

general

keyendees
TitleDemo translationDemo-ÜbersetzungTraducció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

-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

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

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

or

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

Node package

const { generateTranslation } = require('./index');

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

Options

OptionRequiredDescriptionDefault
APIKEYTrueThe airtable apikey-
BASEIDTrueThe ID of the airtable base-
outputfalseThe output directory for translations'.'
beautifyfalseWhether to beautify the generated translation filesfalse
formatfalseThe format of the output filesjs
generateIndexfalseWhether to generate index.js filefalse

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

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

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.1

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago