Registry / database / drizzle-i18n

drizzle-i18n

JSON →
library0.2.0jsnpmunverified

drizzle-i18n is a type-safe database localization layer for Drizzle ORM, at version 0.2.0. It supports two localization strategies: a separate translation table (normalized) or inline JSON column (denormalized), and works with PostgreSQL, MySQL, and SQLite. The package is fully typed with TypeScript, includes mutation helpers for atomic inserts and upserts, and integrates with drizzle-kit for migrations. It has zero runtime dependencies beyond the peer dependency on drizzle-orm >=0.35.0. Differentiators include strict locale typing via createI18n(), fallback support, and a choice between normalized and denormalized schemas. Release cadence is currently low as it is in early development.

npm install drizzle-i18n
INSTALL
IMPORT
SIG · DRIZZLE-I18N
D
drizzle-i18n
databasejavascriptv0.2.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

translationTable
import { translationTable } from 'drizzle-i18n/pg'
import { translationTable } from 'drizzle-i18n'
Must import from dialect-specific subpath (e.g., /pg, /mysql, /sqlite). Top-level import does not export dialect-specific helpers.
withTranslation
import { withTranslation } from 'drizzle-i18n/pg'
import { withTranslation } from 'drizzle-i18n'
Same as translationTable; always use the dialect subpath.
jsonTranslations
import { jsonTranslations } from 'drizzle-i18n/pg'
import { jsonTranslations } from 'drizzle-i18n'
Only available from the dialect-specific module.
createI18n
import { createI18n } from 'drizzle-i18n/pg'
const { createI18n } = require('drizzle-i18n/pg')
Package is ESM-only; require() will fail. Also must be from a dialect subpath.

Shows setting up a product table with separate translation table strategy, then querying with locale 'ar' and fallback 'en'.

import { pgTable, serial, integer, text } from 'drizzle-orm/pg-core'; import { translationTable, withTranslation } from 'drizzle-i18n/pg'; import { drizzle } from 'drizzle-orm/node-postgres'; import { eq } from 'drizzle-orm'; import pg from 'pg'; const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL ?? '' }); const db = drizzle(pool); const products = pgTable('products', { id: serial('id').primaryKey(), sku: text('sku').notNull(), price: integer('price').notNull(), }); const productI18n = translationTable(products, { name: text('name').notNull(), description: text('description'), }); export const productTranslations = productI18n.table; async function main() { const rows = await withTranslation(db, products, productI18n, { locale: 'ar', fallback: 'en', }).where(eq(products.id, 1)); console.log(rows); } main().catch(console.error);
Debug
Known issues
breakingPackage is at version 0.2.0 and may introduce breaking changes in minor/patch versions (pre-1.0).
fix
Pin exact version in package.json (e.g., '0.2.0') and update manually after reviewing changes.
affects: <1.0.0
gotchaImport path must include dialect subpath (/pg, /mysql, /sqlite). Top-level import does not export dialect-specific helpers.
fix
Use import { translationTable } from 'drizzle-i18n/pg' instead of from 'drizzle-i18n'.
affects: >=0.1.0
gotchaThe package is ESM-only. Using require() will throw a runtime error.
fix
Use import syntax instead of require().
affects: >=0.1.0
deprecatedNo deprecations known yet as the package is pre-1.0.
fix
N/A
affects: none
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module /path/to/node_modules/drizzle-i18n/dist/index.mjs not supported.
Package is ESM-only; using CommonJS require() to load it.
fix
Change to import syntax, or set type: 'module' in package.json.
Module not found: Can't resolve 'drizzle-i18n'
Importing from top-level 'drizzle-i18n' instead of a dialect subpath.
fix
Import from 'drizzle-i18n/pg', 'drizzle-i18n/mysql', or 'drizzle-i18n/sqlite'.
TypeError: translationTable is not a function
Using a CommonJS require on an ESM default export or incorrect import.
fix
Use import { translationTable } from 'drizzle-i18n/pg' (named import).
Upgrade
Version history
0.2.0latest on npm
Audit
Dependencies
drizzle-ormrequiredPeer dependency; required for all database operations and type definitions.
Agent activity
10 hits · last 30 days
node
8
Resources
drizzle-i18n — npm install drizzle-i18n · libregistry