chore: TSDocs for Translation Module (#14280)

* tsdocs for translation module

* fixes
This commit is contained in:
Shahed Nasser
2025-12-16 13:30:26 +02:00
committed by GitHub
parent 7b0556dd85
commit 88a3cf7172
36 changed files with 875 additions and 111 deletions

View File

@@ -12,6 +12,14 @@ const Cart = model
sales_channel_id: model.text().nullable(),
email: model.text().nullable(),
currency_code: model.text(),
/**
* The BCP 47 language tag code of the locale
*
* @since 2.12.3
*
* @example
* "en-US"
*/
locale: model.text().nullable(),
metadata: model.json().nullable(),
completed_at: model.dateTime().nullable(),

View File

@@ -1,8 +1,17 @@
import { model } from "@medusajs/framework/utils"
import Store from "./store"
/**
* @since 2.12.3
*/
const StoreLocale = model.define("StoreLocale", {
id: model.id({ prefix: "stloc" }).primaryKey(),
/**
* The BCP 47 language tag code of the locale.
*
* @example
* "en-US"
*/
locale_code: model.text().searchable(),
store: model
.belongsTo(() => Store, {

View File

@@ -13,6 +13,11 @@ const Store = model
supported_currencies: model.hasMany(() => StoreCurrency, {
mappedBy: "store",
}),
/**
* The supported locales of the store.
*
* @since 2.12.3
*/
supported_locales: model.hasMany(() => StoreLocale, {
mappedBy: "store",
}),

View File

@@ -3,8 +3,14 @@ import { model } from "@medusajs/framework/utils"
const Locale = model
.define("locale", {
id: model.id({ prefix: "loc" }).primaryKey(),
code: model.text().searchable(), // BCP 47 language tag, e.g., "en-US", "da-DK"
name: model.text().searchable(), // Human-readable name, e.g., "English (US)", "Danish"
/**
* The BCP 47 language tag code of the locale (e.g., "en-US", "da-DK").
*/
code: model.text().searchable(),
/**
* The human-readable name of the locale (e.g., "English (US)", "Danish").
*/
name: model.text().searchable(),
})
.indexes([
{

View File

@@ -3,11 +3,37 @@ import { model } from "@medusajs/framework/utils"
const Translation = model
.define("translation", {
id: model.id({ prefix: "trans" }).primaryKey(),
/**
* The ID of the entity that the translation belongs to. For example, the ID of a product or a product variant.
*/
reference_id: model.text().searchable(),
reference: model.text().searchable(), // e.g., "product", "product_variant", "product_category"
locale_code: model.text().searchable(), // BCP 47 language tag, e.g., "en-US", "da-DK"
/**
* The name of the table that the translation belongs to. For example, "product" or "product_variant".
*/
reference: model.text().searchable(),
/**
* The BCP 47 language tag code of the locale
*
* @example
* "en-US"
*/
locale_code: model.text().searchable(),
/**
* The translations of the entity.
* The object's keys are the field names of the entity, and its value is the translated value.
*
* @example
* {
* "title": "Product Title",
* "description": "Product Description",
* }
*/
translations: model.json(),
translated_field_count: model.number().default(0), // Precomputed count of translated fields for performance
/**
* Precomputed count of translated fields of a resource.
* Useful for optimization purposes.
*/
translated_field_count: model.number().default(0),
})
.indexes([
{