All Plugins/ORM & Data Modeling/v0.1.0

Veap Translatable

Official

Database translation engine and model trait providing seamless field-level multilingual translations via polymorphic storage.

bun add @veap/translatable

Purpose & Overview

Translates specified model attributes across multiple locales dynamically with fallback support, without altering the underlying table schema.

Installation & Setup

1

Install the package

bash
bun add @veap/translatable
2

Apply trait to your domain Model

models/YourModel.ts
typescript
// models/Page.ts
import { TranslatableModel } from "@veap/translatable";

export class Page extends TranslatableModel {
  static table = "pages";
  static translatable = ["title", "content", "meta_description"];
}

// Storing and retrieving translations:
const page = await Page.find("page-uuid");
page.setTranslation("title", "es", "Página Principal");
page.setTranslation("title", "en", "Home Page");
await page.save();
3

Run database migrations

bash
bun run veap migrate

Keep in mind

  • Translatable attributes are declared as an array on the model: `static translatable = ['title', 'content']`.
  • Supports retrieving localized values for a specific locale with automatic fallback to the default locale.
  • Stores translation values in a central polymorphic `translations` table via `morphMany`.

Dependencies

Veap Core

@veap/core (^0.1.0)

Authors & Maintainers

Veap Core Team

Maintainer

Profile →

Specifications

License
MIT
Type
plugin
Status
official
Repository
GitHub →
veap
Preparing0%