feat: implement i18n for product and category, add 5 new locales

This commit is contained in:
Your Name committed 2026-06-13 23:58:50 -04:00
1 parent b867063efb
commit 96d874233d
17 files changed
+557 -62

No files matched your search

@@ -0,0 +1,22 @@
-- CreateTable
CREATE TABLE "CategoryTranslation" (
"id" SERIAL NOT NULL,
"categoryId" INTEGER NOT NULL,
"langCode" TEXT NOT NULL,
"name" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
CONSTRAINT "CategoryTranslation_pkey" PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "CategoryTranslation_categoryId_langCode_key" ON "CategoryTranslation"("categoryId", "langCode");
-- AddForeignKey
ALTER TABLE "CategoryTranslation" ADD CONSTRAINT "CategoryTranslation_categoryId_fkey" FOREIGN KEY ("categoryId") REFERENCES "Category"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- Seed Thai translations from existing category names
INSERT INTO "CategoryTranslation" ("categoryId", "langCode", "name", "updatedAt")
SELECT id, 'th', name, NOW() FROM "Category"
ON CONFLICT ("categoryId", "langCode") DO NOTHING;
+19 -6
View File
@@ -18,12 +18,25 @@ model Scent {
}
model Category {
id Int @id @default(autoincrement())
name String @unique
imageUrl String?
products Product[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
id Int @id @default(autoincrement())
name String @unique
imageUrl String?
products Product[]
translations CategoryTranslation[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model CategoryTranslation {
id Int @id @default(autoincrement())
categoryId Int
category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade)
langCode String
name String
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@unique([categoryId, langCode])
}
model Product {