@dsi18n/airtable-sync
v0.1.0
Published
Build-time Airtable → dsi18n locale JSON (manifest + per-locale dictionaries).
Readme
@dsi18n/airtable-sync
Build-time tool: pull translation rows from Airtable and write dsi18n locale files (manifest.json, en.json, es.json, …).
Use with @dsi18n/dsi18n at runtime (no Airtable calls in production).
Install
npm install -D @dsi18n/airtable-syncRequires Node.js 18+.
CLI
Create a .env in your project root:
AIRTABLE_API_KEY=pat_...
AIRTABLE_BASE_ID=app...
AIRTABLE_TABLE=Translations
I18N_OUT_DIR=./localesRun:
npx dsi18n-syncdsi18n-sync loads .env from the current directory and parent folders (nested overrides win), then runs the build.
Common env vars
| Variable | Description |
|----------|-------------|
| AIRTABLE_API_KEY | Personal access token |
| AIRTABLE_BASE_ID | Base id (app…) |
| AIRTABLE_TABLE | Table name (or use I18N_TABLES comma-separated) |
| I18N_OUT_DIR | Output directory (default: ./locales) |
| I18N_KEY_FIELD | Key column name (default: key) |
| I18N_DEFAULT_LOCALE | Default locale tag (default: en) |
| I18N_LOCALES | Force locale list, e.g. en,es |
| I18N_TYPES_OUT_FILE | Optional path to generate TranslationKey TypeScript |
| I18N_VERSION | Bundle version string in manifest |
| I18N_DEBUG | 1 or true for verbose logs |
Programmatic API
import {
loadBuildConfigFromEnv,
loadProjectEnv,
runBuild,
} from "@dsi18n/airtable-sync";
loadProjectEnv();
process.env.I18N_OUT_DIR ??= "./locales";
await runBuild(loadBuildConfigFromEnv());package.json script
{
"scripts": {
"i18n:sync": "dsi18n-sync"
},
"devDependencies": {
"@dsi18n/airtable-sync": "^0.1.0"
}
}Commit the generated locales/ folder (or generate in CI before deploy), then load them with @dsi18n/dsi18n.
Output layout
locales/
manifest.json
en.json
es.jsonRelated
- Runtime:
@dsi18n/dsi18n—createI18n,t(),loadLocalesFromDirectory.
License
MIT
