feat(translation,fulfillment,customer,product,region,tax,core-flows,medusa,types): Implement dynamic translation settings management (#14536)

* Add is_active field to translation_settings model

* Types

* Workflows

* Api layer

* Tests

* Add changeset

* Add comment

* Hook to create or deactivate translatable entities on startup

* Cleanup old code

* Configure translatable option for core entities

* Validation step and snake case correction

* Cleanup

* Tests

* Comment in PR

* Update changeset

* Mock DmlEntity.getTranslatableEntities

* Move validation to module service layer

* Remove validation from remaining workflow

* Return object directly

* Type improvements

* Remove .only from tests

* Apply snakeCase

* Fix tests

* Fix tests

* Remove unnecessary map and use set instead

* Fix tests

* Comments

* Include translatable product properties

* Avoid race condition in translations tests

* Update test
This commit is contained in:
Nicolas Gorga
2026-01-14 07:09:49 -03:00
committed by GitHub
parent 42235825ee
commit d60ea7268a
50 changed files with 1397 additions and 199 deletions

View File

@@ -4,8 +4,8 @@ import Product from "./product"
const ProductCategory = model
.define("ProductCategory", {
id: model.id({ prefix: "pcat" }).primaryKey(),
name: model.text().searchable(),
description: model.text().searchable().default(""),
name: model.text().searchable().translatable(),
description: model.text().searchable().translatable().default(""),
handle: model.text().searchable(),
mpath: model.text(),
is_active: model.boolean().default(false),

View File

@@ -4,7 +4,7 @@ import Product from "./product"
const ProductCollection = model
.define("ProductCollection", {
id: model.id({ prefix: "pcol" }).primaryKey(),
title: model.text().searchable(),
title: model.text().searchable().translatable(),
handle: model.text(),
metadata: model.json().nullable(),
products: model.hasMany(() => Product, {

View File

@@ -4,7 +4,7 @@ import { ProductOption, ProductVariant } from "./index"
const ProductOptionValue = model
.define("ProductOptionValue", {
id: model.id({ prefix: "optval" }).primaryKey(),
value: model.text(),
value: model.text().translatable(),
metadata: model.json().nullable(),
option: model
.belongsTo(() => ProductOption, {

View File

@@ -5,7 +5,7 @@ import ProductOptionValue from "./product-option-value"
const ProductOption = model
.define("ProductOption", {
id: model.id({ prefix: "opt" }).primaryKey(),
title: model.text().searchable(),
title: model.text().searchable().translatable(),
metadata: model.json().nullable(),
product: model.belongsTo(() => Product, {
mappedBy: "options",

View File

@@ -6,7 +6,7 @@ const ProductTag = model
{ tableName: "product_tag", name: "ProductTag" },
{
id: model.id({ prefix: "ptag" }).primaryKey(),
value: model.text().searchable(),
value: model.text().searchable().translatable(),
metadata: model.json().nullable(),
products: model.manyToMany(() => Product, {
mappedBy: "tags",

View File

@@ -4,7 +4,7 @@ import { Product } from "@models"
const ProductType = model
.define("ProductType", {
id: model.id({ prefix: "ptyp" }).primaryKey(),
value: model.text().searchable(),
value: model.text().searchable().translatable(),
metadata: model.json().nullable(),
products: model.hasMany(() => Product, {
mappedBy: "type",

View File

@@ -5,7 +5,7 @@ import ProductVariantProductImage from "./product-variant-product-image"
const ProductVariant = model
.define("ProductVariant", {
id: model.id({ prefix: "variant" }).primaryKey(),
title: model.text().searchable(),
title: model.text().searchable().translatable(),
sku: model.text().searchable().nullable(),
barcode: model.text().searchable().nullable(),
ean: model.text().searchable().nullable(),
@@ -15,7 +15,7 @@ const ProductVariant = model
hs_code: model.text().nullable(),
origin_country: model.text().nullable(),
mid_code: model.text().nullable(),
material: model.text().nullable(),
material: model.text().translatable().nullable(),
weight: model.number().nullable(),
length: model.number().nullable(),
height: model.number().nullable(),

View File

@@ -11,10 +11,10 @@ import ProductVariant from "./product-variant"
const Product = model
.define("Product", {
id: model.id({ prefix: "prod" }).primaryKey(),
title: model.text().searchable(),
title: model.text().searchable().translatable(),
handle: model.text(),
subtitle: model.text().searchable().nullable(),
description: model.text().searchable().nullable(),
subtitle: model.text().searchable().translatable().nullable(),
description: model.text().searchable().translatable().nullable(),
is_giftcard: model.boolean().default(false),
status: model
.enum(ProductUtils.ProductStatus)
@@ -27,7 +27,7 @@ const Product = model
origin_country: model.text().nullable(),
hs_code: model.text().nullable(),
mid_code: model.text().nullable(),
material: model.text().nullable(),
material: model.text().translatable().nullable(),
discountable: model.boolean().default(true),
external_id: model.text().nullable(),
metadata: model.json().nullable(),