From 6b0221cfaa9e84dcdc5927434c57a4c76a7ab171 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 20 Nov 2026 06:37:54 +0000 Subject: [PATCH 1/4] WIP: languages, country policies, ad policy, card navigation and PWA prompt placement Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NrPV5wwqB6Kvn6Jo16iwcb --- package.json | 1 + .../migration.sql | 61 +++++++ prisma/schema/admin.prisma | 18 +- prisma/schema/analytics.prisma | 6 +- prisma/schema/community.prisma | 14 +- prisma/schema/growth.prisma | 40 ++-- prisma/schema/identity.prisma | 36 ++-- prisma/schema/international.prisma | 66 +++++++ prisma/schema/moderation.prisma | 14 +- prisma/schema/platform.prisma | 8 +- prisma/schema/security.prisma | 42 ++--- scripts/i18n-check.mjs | 47 +++++ src/app/(public)/about/page.tsx | 13 +- .../account/collections/[id]/page.tsx | 2 +- src/app/(public)/account/collections/page.tsx | 2 +- src/app/(public)/account/favorites/page.tsx | 2 +- .../(public)/account/notifications/page.tsx | 4 +- src/app/(public)/account/reports/page.tsx | 2 +- src/app/(public)/account/reviews/page.tsx | 4 +- .../(public)/app/[slug]/alternatives/page.tsx | 5 +- src/app/(public)/app/[slug]/page.tsx | 100 +++++----- src/app/(public)/apps/page.tsx | 13 +- src/app/(public)/c/[slug]/page.tsx | 22 ++- src/app/(public)/categories/page.tsx | 24 +-- src/app/(public)/collections/[slug]/page.tsx | 3 +- src/app/(public)/forgot-password/page.tsx | 2 +- src/app/(public)/go/[slug]/page.tsx | 6 +- src/app/(public)/layout.tsx | 20 +- src/app/(public)/legal/[type]/page.tsx | 4 +- src/app/(public)/legal/page.tsx | 2 +- src/app/(public)/page.tsx | 69 ++++--- src/app/(public)/report-ad/page.tsx | 45 +++++ src/app/(public)/reset-password/page.tsx | 2 +- src/app/(public)/search/page.tsx | 13 +- src/app/(public)/signin/page.tsx | 2 +- src/app/(public)/signup/page.tsx | 2 +- src/app/admin-host/(portal)/layout.tsx | 3 + src/app/ads/frame/[unit]/route.ts | 7 +- src/app/globals.css | 15 ++ src/app/layout.tsx | 6 +- src/components/account-menu.tsx | 41 +++-- src/components/account/account-nav.tsx | 6 +- src/components/ads/ad-slot.tsx | 12 +- src/components/ads/ad.tsx | 29 ++- src/components/app-card.tsx | 4 +- src/components/auth/auth-forms.tsx | 4 +- .../community/add-to-collection.tsx | 4 +- src/components/community/favorite-button.tsx | 2 +- src/components/community/review-form.tsx | 2 +- src/components/community/reviews-section.tsx | 10 +- src/components/cookie-consent.tsx | 29 +-- src/components/error-page.tsx | 4 +- src/components/filter-bar.tsx | 6 +- src/components/header-search.tsx | 4 +- src/components/language-menu.tsx | 122 +++++++++++++ src/components/locale-sync.tsx | 20 ++ src/components/mobile-nav.tsx | 18 +- src/components/not-found-view.tsx | 9 +- src/components/pagination.tsx | 2 +- src/components/push-toggle.tsx | 4 +- src/components/pwa.tsx | 36 ++-- src/components/rail.tsx | 11 +- src/components/search-box.tsx | 6 +- src/components/site-footer.tsx | 39 ++-- src/components/site-header.tsx | 24 ++- src/components/store-sections.tsx | 39 ++-- src/components/theme-toggle.tsx | 6 +- src/components/ui/button.tsx | 2 +- src/components/ui/password-input.tsx | 4 +- src/i18n/catalogs.ts | 31 ++++ src/i18n/client.tsx | 48 +++++ src/i18n/coverage.ts | 33 ++++ src/i18n/format.ts | 39 ++++ src/i18n/locales.ts | 166 +++++++++++++++++ src/i18n/messages/categories/ar.json | 60 ++++++ src/i18n/messages/categories/de.json | 60 ++++++ src/i18n/messages/categories/en.json | 60 ++++++ src/i18n/messages/categories/es.json | 60 ++++++ src/i18n/messages/categories/fr.json | 60 ++++++ src/i18n/messages/categories/hi.json | 60 ++++++ src/i18n/messages/categories/it.json | 60 ++++++ src/i18n/messages/categories/ja.json | 60 ++++++ src/i18n/messages/categories/ko.json | 60 ++++++ src/i18n/messages/categories/nl.json | 60 ++++++ src/i18n/messages/categories/pl.json | 60 ++++++ src/i18n/messages/categories/pt-BR.json | 60 ++++++ src/i18n/messages/categories/ru.json | 60 ++++++ src/i18n/messages/categories/tr.json | 60 ++++++ src/i18n/messages/categories/zh-Hans.json | 60 ++++++ src/i18n/messages/common/ar.json | 83 +++++++++ src/i18n/messages/common/de.json | 84 +++++++++ src/i18n/messages/common/en.json | 84 +++++++++ src/i18n/messages/common/es.json | 84 +++++++++ src/i18n/messages/common/fr.json | 84 +++++++++ src/i18n/messages/common/hi.json | 83 +++++++++ src/i18n/messages/common/it.json | 84 +++++++++ src/i18n/messages/common/ja.json | 83 +++++++++ src/i18n/messages/common/ko.json | 83 +++++++++ src/i18n/messages/common/nl.json | 84 +++++++++ src/i18n/messages/common/pl.json | 83 +++++++++ src/i18n/messages/common/pt-BR.json | 84 +++++++++ src/i18n/messages/common/ru.json | 83 +++++++++ src/i18n/messages/common/tr.json | 83 +++++++++ src/i18n/messages/common/zh-Hans.json | 83 +++++++++ src/i18n/messages/meta.json | 77 ++++++++ src/i18n/messages/store/ar.json | 79 ++++++++ src/i18n/messages/store/de.json | 82 +++++++++ src/i18n/messages/store/en.json | 82 +++++++++ src/i18n/messages/store/es.json | 82 +++++++++ src/i18n/messages/store/fr.json | 82 +++++++++ src/i18n/messages/store/hi.json | 80 ++++++++ src/i18n/messages/store/it.json | 82 +++++++++ src/i18n/messages/store/ja.json | 79 ++++++++ src/i18n/messages/store/ko.json | 79 ++++++++ src/i18n/messages/store/nl.json | 82 +++++++++ src/i18n/messages/store/pl.json | 79 ++++++++ src/i18n/messages/store/pt-BR.json | 82 +++++++++ src/i18n/messages/store/ru.json | 79 ++++++++ src/i18n/messages/store/tr.json | 79 ++++++++ src/i18n/messages/store/zh-Hans.json | 79 ++++++++ src/i18n/routing.ts | 46 +++++ src/i18n/seo-rules.ts | 55 ++++++ src/i18n/server.ts | 31 ++++ src/i18n/translate.ts | 50 +++++ src/lib/ad-report.ts | 9 + src/proxy.ts | 50 ++++- src/server/actions/international.ts | 138 ++++++++++++++ src/server/actions/locale.ts | 14 ++ src/server/actions/public.ts | 26 ++- src/server/ads/content-policy.ts | 41 +++++ src/server/ads/manager.ts | 2 +- src/server/ads/placements.ts | 9 +- src/server/auth/session.ts | 3 +- src/server/catalog/visibility.ts | 4 +- src/server/geo/country-policy.ts | 48 +++++ src/server/i18n/categories.ts | 21 +++ src/server/i18n/seo.ts | 25 +++ src/server/i18n/settings.ts | 10 + src/server/settings/registry.ts | 53 +++++- src/server/viewer.ts | 41 ++++- tests/e2e/journeys.spec.ts | 4 +- tests/e2e/marketplace.spec.ts | 2 +- tests/e2e/repair.spec.ts | 20 +- tests/unit/i18n.test.ts | 172 ++++++++++++++++++ 144 files changed, 5464 insertions(+), 409 deletions(-) create mode 100644 prisma/migrations/20261116120000_international/migration.sql create mode 100644 prisma/schema/international.prisma create mode 100644 scripts/i18n-check.mjs create mode 100644 src/app/(public)/report-ad/page.tsx create mode 100644 src/components/language-menu.tsx create mode 100644 src/components/locale-sync.tsx create mode 100644 src/i18n/catalogs.ts create mode 100644 src/i18n/client.tsx create mode 100644 src/i18n/coverage.ts create mode 100644 src/i18n/format.ts create mode 100644 src/i18n/locales.ts create mode 100644 src/i18n/messages/categories/ar.json create mode 100644 src/i18n/messages/categories/de.json create mode 100644 src/i18n/messages/categories/en.json create mode 100644 src/i18n/messages/categories/es.json create mode 100644 src/i18n/messages/categories/fr.json create mode 100644 src/i18n/messages/categories/hi.json create mode 100644 src/i18n/messages/categories/it.json create mode 100644 src/i18n/messages/categories/ja.json create mode 100644 src/i18n/messages/categories/ko.json create mode 100644 src/i18n/messages/categories/nl.json create mode 100644 src/i18n/messages/categories/pl.json create mode 100644 src/i18n/messages/categories/pt-BR.json create mode 100644 src/i18n/messages/categories/ru.json create mode 100644 src/i18n/messages/categories/tr.json create mode 100644 src/i18n/messages/categories/zh-Hans.json create mode 100644 src/i18n/messages/common/ar.json create mode 100644 src/i18n/messages/common/de.json create mode 100644 src/i18n/messages/common/en.json create mode 100644 src/i18n/messages/common/es.json create mode 100644 src/i18n/messages/common/fr.json create mode 100644 src/i18n/messages/common/hi.json create mode 100644 src/i18n/messages/common/it.json create mode 100644 src/i18n/messages/common/ja.json create mode 100644 src/i18n/messages/common/ko.json create mode 100644 src/i18n/messages/common/nl.json create mode 100644 src/i18n/messages/common/pl.json create mode 100644 src/i18n/messages/common/pt-BR.json create mode 100644 src/i18n/messages/common/ru.json create mode 100644 src/i18n/messages/common/tr.json create mode 100644 src/i18n/messages/common/zh-Hans.json create mode 100644 src/i18n/messages/meta.json create mode 100644 src/i18n/messages/store/ar.json create mode 100644 src/i18n/messages/store/de.json create mode 100644 src/i18n/messages/store/en.json create mode 100644 src/i18n/messages/store/es.json create mode 100644 src/i18n/messages/store/fr.json create mode 100644 src/i18n/messages/store/hi.json create mode 100644 src/i18n/messages/store/it.json create mode 100644 src/i18n/messages/store/ja.json create mode 100644 src/i18n/messages/store/ko.json create mode 100644 src/i18n/messages/store/nl.json create mode 100644 src/i18n/messages/store/pl.json create mode 100644 src/i18n/messages/store/pt-BR.json create mode 100644 src/i18n/messages/store/ru.json create mode 100644 src/i18n/messages/store/tr.json create mode 100644 src/i18n/messages/store/zh-Hans.json create mode 100644 src/i18n/routing.ts create mode 100644 src/i18n/seo-rules.ts create mode 100644 src/i18n/server.ts create mode 100644 src/i18n/translate.ts create mode 100644 src/lib/ad-report.ts create mode 100644 src/server/actions/international.ts create mode 100644 src/server/actions/locale.ts create mode 100644 src/server/ads/content-policy.ts create mode 100644 src/server/geo/country-policy.ts create mode 100644 src/server/i18n/categories.ts create mode 100644 src/server/i18n/seo.ts create mode 100644 src/server/i18n/settings.ts create mode 100644 tests/unit/i18n.test.ts diff --git a/package.json b/package.json index 5d7c02d..2576d4c 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "build": "prisma generate && next build --webpack", "start": "node .next/standalone/server.js", "lint": "eslint .", + "i18n:check": "node scripts/i18n-check.mjs", "test": "vitest run", "test:e2e": "playwright test", "db:seed": "tsx scripts/seed.ts", diff --git a/prisma/migrations/20261116120000_international/migration.sql b/prisma/migrations/20261116120000_international/migration.sql new file mode 100644 index 0000000..9152bf0 --- /dev/null +++ b/prisma/migrations/20261116120000_international/migration.sql @@ -0,0 +1,61 @@ +-- CreateTable +CREATE TABLE `CountryPolicy` ( + `country` CHAR(2) NOT NULL, + `restrictedCategories` JSON NOT NULL, + `permittedCategories` JSON NOT NULL, + `adultAge` INTEGER NULL, + `adsDisabled` BOOLEAN NOT NULL DEFAULT false, + `disabledProviders` JSON NOT NULL, + `lastReviewedAt` DATETIME(3) NULL, + `notes` TEXT NULL, + `updatedById` VARCHAR(191) NULL, + `updatedAt` DATETIME(3) NOT NULL, + `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + + PRIMARY KEY (`country`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `AdReport` ( + `id` VARCHAR(191) NOT NULL, + `placement` VARCHAR(40) NOT NULL, + `provider` VARCHAR(20) NOT NULL, + `pagePath` VARCHAR(300) NOT NULL, + `country` CHAR(2) NULL, + `reason` VARCHAR(40) NOT NULL, + `details` VARCHAR(1000) NULL, + `status` VARCHAR(20) NOT NULL DEFAULT 'open', + `resolution` VARCHAR(500) NULL, + `resolvedById` VARCHAR(191) NULL, + `resolvedAt` DATETIME(3) NULL, + `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), + + INDEX `AdReport_status_createdAt_idx`(`status`, `createdAt`), + PRIMARY KEY (`id`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `CategoryTranslation` ( + `categoryId` VARCHAR(191) NOT NULL, + `locale` VARCHAR(16) NOT NULL, + `name` VARCHAR(120) NOT NULL, + `description` VARCHAR(500) NULL, + `reviewed` BOOLEAN NOT NULL DEFAULT false, + `updatedById` VARCHAR(191) NULL, + `updatedAt` DATETIME(3) NOT NULL, + + INDEX `CategoryTranslation_locale_idx`(`locale`), + PRIMARY KEY (`categoryId`, `locale`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; + +-- CreateTable +CREATE TABLE `LocaleSeo` ( + `locale` VARCHAR(16) NOT NULL, + `title` VARCHAR(70) NULL, + `description` VARCHAR(170) NULL, + `keywords` JSON NOT NULL, + `updatedById` VARCHAR(191) NULL, + `updatedAt` DATETIME(3) NOT NULL, + + PRIMARY KEY (`locale`) +) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; diff --git a/prisma/schema/admin.prisma b/prisma/schema/admin.prisma index d455982..a52fc03 100644 --- a/prisma/schema/admin.prisma +++ b/prisma/schema/admin.prisma @@ -28,9 +28,9 @@ model AdminUser { role AdminRole status AdminStatus @default(ACTIVE) /// argon2id/scrypt hash. Never logged. - passwordHash String @db.VarChar(255) + passwordHash String @db.VarChar(255) /// TOTP seed encrypted with FIELD_ENCRYPTION_KEY (AES-256-GCM). - totpSecretEnc String? @db.Text + totpSecretEnc String? @db.Text totpEnabledAt DateTime? @db.DateTime(3) /// Last accepted TOTP time-step (prevents code replay). totpLastStep Int? @@ -79,7 +79,7 @@ model AdminSession { expiresAt DateTime @db.DateTime(3) lastSeenAt DateTime @default(now()) @db.DateTime(3) ipAddress String? - userAgent String? @db.Text + userAgent String? @db.Text revokedAt DateTime? @db.DateTime(3) /// Last time the administrator re-confirmed with an authenticator code (sensitive actions). stepUpAt DateTime? @db.DateTime(3) @@ -93,10 +93,10 @@ model AdminSession { model AdminInvitation { id String @id @default(uuid(7)) - email String @db.VarChar(254) + email String @db.VarChar(254) role AdminRole /// Set while the invitee enrols TOTP (encrypted); moved to AdminUser on acceptance. - pendingTotpEnc String? @db.Text + pendingTotpEnc String? @db.Text /// SHA-256 of the single-use invitation token. tokenHash String @unique @db.VarChar(64) /// Null only for the bootstrap Super Administrator created by the provisioning CLI. @@ -114,12 +114,12 @@ model AdminInvitation { model AdminLoginEvent { id String @id @default(uuid(7)) adminId String? - emailAttempted String @db.Text + emailAttempted String @db.Text success Boolean /// e.g. "bad_password", "bad_totp", "locked", "suspended" - failureReason String? @db.Text + failureReason String? @db.Text ipAddress String? - userAgent String? @db.Text + userAgent String? @db.Text createdAt DateTime @default(now()) @db.DateTime(3) admin AdminUser? @relation(fields: [adminId], references: [id], onDelete: SetNull) @@ -144,7 +144,7 @@ model AuditLog { /// Before/after diff or other context. Never contains secrets. metadata Json? ipAddress String? - userAgent String? @db.Text + userAgent String? @db.Text createdAt DateTime @default(now()) @db.DateTime(3) admin AdminUser? @relation(fields: [adminId], references: [id], onDelete: SetNull) diff --git a/prisma/schema/analytics.prisma b/prisma/schema/analytics.prisma index 0366d86..35b7651 100644 --- a/prisma/schema/analytics.prisma +++ b/prisma/schema/analytics.prisma @@ -58,7 +58,7 @@ model ListingEvent { countryCode String? @db.Char(2) device DeviceType @default(UNKNOWN) /// Referrer host only (no path/query) to avoid leaking third-party URLs. - referrerHost String? @db.VarChar(255) + referrerHost String? @db.VarChar(255) /// Internal surface that produced the event, e.g. "search", "home:trending". surface String? @@ -89,7 +89,7 @@ model ListingDailyDimensionStat { date DateTime @db.Date dimension StatDimension /// Country code, device type or referrer host. - key String @db.VarChar(255) + key String @db.VarChar(255) views Int @default(0) outboundClicks Int @default(0) @@ -119,7 +119,7 @@ model InteractionEvent { type InteractionType listingId String? categoryId String? - query String? @db.Text + query String? @db.Text dwellMs Int? createdAt DateTime @default(now()) @db.DateTime(3) diff --git a/prisma/schema/community.prisma b/prisma/schema/community.prisma index 3cd6493..5bd3fee 100644 --- a/prisma/schema/community.prisma +++ b/prisma/schema/community.prisma @@ -42,7 +42,7 @@ model Review { /// 1–5, enforced by a CHECK constraint added in the migration. rating Int title String? - body String? @db.Text + body String? @db.Text status ReviewStatus @default(PUBLISHED) /// Only true when a real verification mechanism exists (e.g. a future developer /// integration). There is no such mechanism yet, so this stays false. @@ -75,7 +75,7 @@ model ReviewReply { reviewId String @unique orgId String authorUserId String? - body String @db.Text + body String @db.Text status ReviewStatus @default(PUBLISHED) editedAt DateTime? @db.DateTime(3) createdAt DateTime @default(now()) @db.DateTime(3) @@ -116,7 +116,7 @@ model Collection { id String @id @default(uuid(7)) slug String @unique title String - description String? @db.Text + description String? @db.Text ownerId String? isEditorial Boolean @default(false) visibility CollectionVisibility @default(PRIVATE) @@ -136,7 +136,7 @@ model CollectionItem { collectionId String listingId String sortOrder Int @default(0) - note String? @db.Text + note String? @db.Text addedAt DateTime @default(now()) @db.DateTime(3) collection Collection @relation(fields: [collectionId], references: [id], onDelete: Cascade) @@ -150,10 +150,10 @@ model Notification { id String @id @default(uuid(7)) userId String type NotificationType - title String @db.Text - body String? @db.Text + title String @db.Text + body String? @db.Text /// Relative in-app path only (never an external URL). - linkPath String? @db.Text + linkPath String? @db.Text data Json? readAt DateTime? @db.DateTime(3) createdAt DateTime @default(now()) @db.DateTime(3) diff --git a/prisma/schema/growth.prisma b/prisma/schema/growth.prisma index 77ac947..9dfb8f2 100644 --- a/prisma/schema/growth.prisma +++ b/prisma/schema/growth.prisma @@ -92,34 +92,34 @@ enum ImportStatus { /// A web app waiting to be imported automatically (site details, logo and screenshots are /// fetched from the site itself, then it goes through the normal security checks). model ImportCandidate { - id String @id @default(uuid(7)) + id String @id @default(uuid(7)) /// SHA-256 of the normalised URL. - urlHash String @unique @db.Char(64) - url String @db.VarChar(2000) - domain String @db.VarChar(253) + urlHash String @unique @db.Char(64) + url String @db.VarChar(2000) + domain String @db.VarChar(253) /// Category slug to file it under (a top-level or a subcategory). - categorySlug String? @db.VarChar(191) + categorySlug String? @db.VarChar(191) /// Optional name and summary from the person or list that suggested it. - name String? @db.VarChar(120) - note String? @db.Text + name String? @db.VarChar(120) + note String? @db.Text /// "catalogue" (Webcenta's researched list) or "admin". - source String @default("admin") @db.VarChar(40) - status ImportStatus @default(QUEUED) + source String @default("admin") @db.VarChar(40) + status ImportStatus @default(QUEUED) /// Never publish automatically: always wait for a moderator ("Send for review"). - reviewRequired Boolean @default(false) - priority Int @default(0) - attempts Int @default(0) - listingId String? - lastError String? @db.Text + reviewRequired Boolean @default(false) + priority Int @default(0) + attempts Int @default(0) + listingId String? + lastError String? @db.Text /// Where the last attempt failed (fetch, metadata, duplicate, category, listing, checks) and why. - failedStage String? @db.VarChar(40) - errorCategory String? @db.VarChar(40) - retryable Boolean @default(true) + failedStage String? @db.VarChar(40) + errorCategory String? @db.VarChar(40) + retryable Boolean @default(true) /// The existing listing this import duplicates (set by duplicate detection; never published). duplicateOfListingId String? - createdByAdminId String? - createdAt DateTime @default(now()) @db.DateTime(3) - processedAt DateTime? @db.DateTime(3) + createdByAdminId String? + createdAt DateTime @default(now()) @db.DateTime(3) + processedAt DateTime? @db.DateTime(3) @@index([status, priority, createdAt]) @@index([domain]) diff --git a/prisma/schema/identity.prisma b/prisma/schema/identity.prisma index de857a8..622558e 100644 --- a/prisma/schema/identity.prisma +++ b/prisma/schema/identity.prisma @@ -32,10 +32,10 @@ model User { email String @unique @db.VarChar(254) emailVerified Boolean @default(false) name String - image String? @db.Text + image String? @db.Text status UserStatus @default(ACTIVE) suspendedAt DateTime? @db.DateTime(3) - suspendReason String? @db.Text + suspendReason String? @db.Text // --- Privacy & personalisation preferences (privacy by default) --- personalizationEnabled Boolean @default(true) @@ -99,7 +99,7 @@ model Session { userId String expiresAt DateTime @db.DateTime(3) ipAddress String? - userAgent String? @db.Text + userAgent String? @db.Text createdAt DateTime @default(now()) @db.DateTime(3) updatedAt DateTime @updatedAt @db.DateTime(3) @@ -117,14 +117,14 @@ model Account { accountId String /// e.g. "credential", "google", "apple" providerId String - accessToken String? @db.Text - refreshToken String? @db.Text - idToken String? @db.Text + accessToken String? @db.Text + refreshToken String? @db.Text + idToken String? @db.Text accessTokenExpiresAt DateTime? @db.DateTime(3) refreshTokenExpiresAt DateTime? @db.DateTime(3) - scope String? @db.Text + scope String? @db.Text /// Password hash (scrypt/argon2) for the credential provider only. - password String? @db.Text + password String? @db.Text createdAt DateTime @default(now()) @db.DateTime(3) updatedAt DateTime @updatedAt @db.DateTime(3) @@ -137,8 +137,8 @@ model Account { /// Short-lived tokens: email verification, password reset, magic links. model Verification { id String @id @default(uuid(7)) - identifier String @db.VarChar(255) - value String @db.Text + identifier String @db.VarChar(255) + value String @db.Text expiresAt DateTime @db.DateTime(3) createdAt DateTime @default(now()) @db.DateTime(3) updatedAt DateTime @updatedAt @db.DateTime(3) @@ -152,10 +152,10 @@ model AuthEvent { id String @id @default(uuid(7)) userId String? /// Email attempted, kept for failed logins where no user matched. - email String? @db.VarChar(254) + email String? @db.VarChar(254) type AuthEventType ipAddress String? - userAgent String? @db.Text + userAgent String? @db.Text metadata Json? createdAt DateTime @default(now()) @db.DateTime(3) @@ -177,17 +177,17 @@ model AuthRateLimit { /// EMAIL_TRANSPORT=log (development/tests) messages are only recorded. model EmailMessage { id String @id @default(uuid(7)) - to String @db.VarChar(254) + to String @db.VarChar(254) /// Where replies go (e.g. the visitor who wrote to support). - replyTo String? @db.VarChar(254) - subject String @db.Text - text String @db.MediumText - html String? @db.MediumText + replyTo String? @db.VarChar(254) + subject String @db.Text + text String @db.MediumText + html String? @db.MediumText /// e.g. "verify-email", "reset-password", "review-reply" template String status String @default("PENDING") attempts Int @default(0) - lastError String? @db.Text + lastError String? @db.Text sentAt DateTime? @db.DateTime(3) createdAt DateTime @default(now()) @db.DateTime(3) diff --git a/prisma/schema/international.prisma b/prisma/schema/international.prisma new file mode 100644 index 0000000..826563e --- /dev/null +++ b/prisma/schema/international.prisma @@ -0,0 +1,66 @@ +/// Admin-maintained policy for one country: categories hidden there (on top of the global +/// rules), the minimum age for adult content, and advertising restrictions. A row only ever +/// adds restrictions; a user's chosen country can never relax the detected country's row. +model CountryPolicy { + /// ISO 3166-1 alpha-2, upper case. + country String @id @db.Char(2) + /// Category slugs hidden in this country (listings in them, or in their children, are hidden). + restrictedCategories Json + /// Restricted-by-default categories explicitly permitted here (documentation; never overrides a global block). + permittedCategories Json + /// Minimum age for 18+ content in this country (null: the built-in age-of-majority table). + adultAge Int? + /// No advertising at all for visitors from this country. + adsDisabled Boolean @default(false) + /// Ad providers switched off here, e.g. ["adsterra"]. + disabledProviders Json + lastReviewedAt DateTime? @db.DateTime(3) + notes String? @db.Text + updatedById String? + updatedAt DateTime @updatedAt @db.DateTime(3) + createdAt DateTime @default(now()) @db.DateTime(3) +} + +/// A visitor's report about an advertisement they saw. Creatives are served by the provider +/// inside a sandboxed frame we cannot inspect, so the report records where and when. +model AdReport { + id String @id @default(uuid(7)) + placement String @db.VarChar(40) + provider String @db.VarChar(20) + pagePath String @db.VarChar(300) + /// Country code only (never the IP address). + country String? @db.Char(2) + reason String @db.VarChar(40) + details String? @db.VarChar(1000) + status String @default("open") @db.VarChar(20) + resolution String? @db.VarChar(500) + resolvedById String? + resolvedAt DateTime? @db.DateTime(3) + createdAt DateTime @default(now()) @db.DateTime(3) + + @@index([status, createdAt]) +} + +/// Translated name and description of a category (admin-edited; overrides the bundled catalogue). +model CategoryTranslation { + categoryId String + locale String @db.VarChar(16) + name String @db.VarChar(120) + description String? @db.VarChar(500) + reviewed Boolean @default(false) + updatedById String? + updatedAt DateTime @updatedAt @db.DateTime(3) + + @@id([categoryId, locale]) + @@index([locale]) +} + +/// Per-language search metadata for the homepage (title, description and keywords). +model LocaleSeo { + locale String @id @db.VarChar(16) + title String? @db.VarChar(70) + description String? @db.VarChar(170) + keywords Json + updatedById String? + updatedAt DateTime @updatedAt @db.DateTime(3) +} diff --git a/prisma/schema/moderation.prisma b/prisma/schema/moderation.prisma index 423953b..9b479e5 100644 --- a/prisma/schema/moderation.prisma +++ b/prisma/schema/moderation.prisma @@ -80,12 +80,12 @@ model Report { /// Null for anonymous reports (allowed for listings, rate-limited). reporterId String? reason ReportReason - details String? @db.Text + details String? @db.Text /// For copyright complaints: claimant identity/contact and the work concerned. claimantDetails Json? status ReportStatus @default(OPEN) assignedAdminId String? - resolutionNotes String? @db.Text + resolutionNotes String? @db.Text resolvedAt DateTime? @db.DateTime(3) createdAt DateTime @default(now()) @db.DateTime(3) updatedAt DateTime @updatedAt @db.DateTime(3) @@ -114,7 +114,7 @@ model ModerationAction { action ModerationActionType targetType String targetId String - reason String @db.Text + reason String @db.Text reportId String? appealId String? metadata Json? @@ -134,9 +134,9 @@ model Appeal { listingId String? /// The moderation action being appealed, by id (kept as plain id to avoid cycles). originalActionId String? - statement String @db.Text + statement String @db.Text status AppealStatus @default(OPEN) - decisionNotes String? @db.Text + decisionNotes String? @db.Text decidedById String? decidedAt DateTime? @db.DateTime(3) createdAt DateTime @default(now()) @db.DateTime(3) @@ -152,7 +152,7 @@ model Appeal { model SupportCase { id String @id @default(uuid(7)) userId String? - contactEmail String @db.VarChar(254) + contactEmail String @db.VarChar(254) subject String status SupportCaseStatus @default(OPEN) assignedAdminId String? @@ -173,7 +173,7 @@ model SupportCaseMessage { fromAdminId String? /// Internal notes are never shown to the user. isInternal Boolean @default(false) - body String @db.Text + body String @db.Text createdAt DateTime @default(now()) @db.DateTime(3) case SupportCase @relation(fields: [caseId], references: [id], onDelete: Cascade) diff --git a/prisma/schema/platform.prisma b/prisma/schema/platform.prisma index f3fdb05..1123bd1 100644 --- a/prisma/schema/platform.prisma +++ b/prisma/schema/platform.prisma @@ -89,7 +89,7 @@ model FeaturedPlacement { model SystemSetting { key String @id value Json - description String? @db.Text + description String? @db.Text updatedByAdminId String? updatedAt DateTime @updatedAt @db.DateTime(3) @@ -102,7 +102,7 @@ model LegalPolicy { version Int title String /// Markdown, rendered with a sanitising renderer. - body String @db.MediumText + body String @db.MediumText effectiveAt DateTime @db.DateTime(3) publishedAt DateTime? @db.DateTime(3) createdByAdminId String? @@ -158,8 +158,8 @@ model Sponsorship { slot PlacementSlot @default(HOME_FEATURED) startsAt DateTime? @db.DateTime(3) endsAt DateTime? @db.DateTime(3) - message String? @db.Text - decisionNotes String? @db.Text + message String? @db.Text + decisionNotes String? @db.Text createdAt DateTime @default(now()) @db.DateTime(3) org DeveloperOrg @relation(fields: [orgId], references: [id], onDelete: Cascade) diff --git a/prisma/schema/security.prisma b/prisma/schema/security.prisma index 889714b..2ac1200 100644 --- a/prisma/schema/security.prisma +++ b/prisma/schema/security.prisma @@ -71,21 +71,21 @@ model SecurityScan { overallVerdict CheckVerdict? /// 0–100, higher = riskier. Input to the approval engine, not a public score. riskScore Int? - targetUrl String @db.Text - finalUrl String? @db.Text + targetUrl String @db.Text + finalUrl String? @db.Text httpStatus Int? redirectChain Json? - resolvedIps Json @default("[]") - nameservers Json @default("[]") - tlsIssuer String? @db.Text + resolvedIps Json @default("[]") + nameservers Json @default("[]") + tlsIssuer String? @db.Text tlsValidTo DateTime? @db.DateTime(3) tlsFingerprint String? - pageTitle String? @db.Text + pageTitle String? @db.Text /// Hash of normalised visible text, for change detection. contentHash String? bytesFetched Int? durationMs Int? - error String? @db.Text + error String? @db.Text requestedByAdminId String? startedAt DateTime? @db.DateTime(3) completedAt DateTime? @db.DateTime(3) @@ -108,7 +108,7 @@ model SecurityCheckResult { /// e.g. "internal", "google-web-risk", "urlhaus", "virustotal" provider String verdict CheckVerdict - summary String? @db.Text + summary String? @db.Text /// Structured evidence (provider response excerpt, matched indicators). evidence Json? durationMs Int? @@ -126,13 +126,13 @@ model SecurityAlert { scanId String? severity AlertSeverity status AlertStatus @default(OPEN) - title String @db.Text - details String? @db.Text + title String @db.Text + details String? @db.Text evidence Json? /// True when the system restricted visibility automatically. autoRestricted Boolean @default(false) assignedAdminId String? - resolutionNotes String? @db.Text + resolutionNotes String? @db.Text resolvedAt DateTime? @db.DateTime(3) createdAt DateTime @default(now()) @db.DateTime(3) updatedAt DateTime @updatedAt @db.DateTime(3) @@ -160,18 +160,18 @@ model MonitoringPolicy { /// new-device admin sign-ins, blocked requests), counted per type, source and hour so a flood /// produces one row, not millions. Never contains passwords, tokens or cookies. Kept 90 days. model SecurityEvent { - id String @id @default(uuid(7)) - type String @db.VarChar(40) - severity String @default("info") @db.VarChar(10) + id String @id @default(uuid(7)) + type String @db.VarChar(40) + severity String @default("info") @db.VarChar(10) /// Source: an IP address, an account id or a rate-limit scope (no secrets). - source String @db.VarChar(191) - detail String? @db.VarChar(500) - hour DateTime @db.DateTime(3) - count Int @default(1) - firstAt DateTime @default(now()) @db.DateTime(3) - lastAt DateTime @default(now()) @db.DateTime(3) + source String @db.VarChar(191) + detail String? @db.VarChar(500) + hour DateTime @db.DateTime(3) + count Int @default(1) + firstAt DateTime @default(now()) @db.DateTime(3) + lastAt DateTime @default(now()) @db.DateTime(3) /// An alert email was sent for this row. - alertedAt DateTime? @db.DateTime(3) + alertedAt DateTime? @db.DateTime(3) @@unique([type, source, hour]) @@index([hour]) diff --git a/scripts/i18n-check.mjs b/scripts/i18n-check.mjs new file mode 100644 index 0000000..127cef6 --- /dev/null +++ b/scripts/i18n-check.mjs @@ -0,0 +1,47 @@ +#!/usr/bin/env node +// Checks every translation catalogue against English: missing keys, keys English does not have, +// placeholder mismatches, empty values and markup. Exit code 1 on errors (not on missing keys, +// which fall back to English and are reported as coverage). +// node scripts/i18n-check.mjs summary per language +// node scripts/i18n-check.mjs --missing also list missing keys +import { readFileSync, readdirSync, existsSync } from "node:fs"; +import { join } from "node:path"; + +const root = join(import.meta.dirname, "..", "src", "i18n", "messages"); +const namespaces = readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((d) => d.name); +const locales = [...readFileSync(join(import.meta.dirname, "..", "src", "i18n", "locales.ts"), "utf8").matchAll(/L\("([A-Za-z-]+)"/g)].map((m) => m[1]); +const showMissing = process.argv.includes("--missing"); +const texts = (v) => (typeof v === "string" ? [v] : v && typeof v === "object" ? Object.values(v) : []); +const ph = (v) => [...new Set(texts(v).flatMap((t) => [...String(t).matchAll(/\{(\w+)\}/g)].map((m) => m[1])))].sort().join(); + +let errors = 0; +const rows = []; +for (const locale of locales) { + let total = 0, done = 0; const missing = []; const problems = []; + for (const ns of namespaces) { + const en = JSON.parse(readFileSync(join(root, ns, "en.json"), "utf8")); + const file = join(root, ns, `${locale}.json`); + const other = existsSync(file) ? JSON.parse(readFileSync(file, "utf8")) : {}; + for (const [key, ev] of Object.entries(en)) { + total++; + const v = other[key]; + if (v === undefined) { missing.push(`${ns}:${key}`); continue; } + const t = texts(v); + if (!t.length || (t.some((x) => !String(x).trim()) && !/(Before|After)$/.test(key))) problems.push(`${ns}:${key} empty`); + else if (t.some((x) => /<[a-z/!]|javascript:|on\w+=/i.test(String(x)))) problems.push(`${ns}:${key} contains markup`); + else if (typeof ev !== typeof v) problems.push(`${ns}:${key} plural forms differ from English`); + else if (ph(ev) !== ph(v)) problems.push(`${ns}:${key} placeholders differ`); + else done++; + } + for (const key of Object.keys(other)) if (!(key in en)) problems.push(`${ns}:${key} not in English`); + } + errors += problems.length; + rows.push({ locale, pct: Math.floor((done / total) * 100), done, total, problems, missing }); +} +for (const r of rows) { + console.log(`${r.locale.padEnd(8)} ${String(r.pct).padStart(3)}% ${r.done}/${r.total}${r.problems.length ? ` ERRORS: ${r.problems.length}` : ""}`); + for (const p of r.problems) console.log(` ✗ ${p}`); + if (showMissing && r.missing.length && r.missing.length < r.total) for (const m of r.missing) console.log(` · missing ${m}`); +} +console.log(`\n${rows.filter((r) => r.pct === 100).length} of ${rows.length} languages have every key; ${rows.filter((r) => r.pct === 0).length} have none (English is shown).`); +process.exit(errors ? 1 : 0); diff --git a/src/app/(public)/about/page.tsx b/src/app/(public)/about/page.tsx index f141391..4a1a8f8 100644 --- a/src/app/(public)/about/page.tsx +++ b/src/app/(public)/about/page.tsx @@ -1,10 +1,13 @@ +import { seoAlternates } from "@/server/i18n/seo"; import type { Metadata } from "next"; -export const metadata: Metadata = { - title: "About Webcenta", - description: "What Webcenta is, how listings are added and checked, and how rankings work.", - alternates: { canonical: "/about" }, -}; +export async function generateMetadata(): Promise { + return { + title: "About Webcenta", + description: "What Webcenta is, how listings are added and checked, and how rankings work.", + ...(await seoAlternates("/about", "original")), + }; +} export default function AboutPage() { const h2 = "mt-8 text-xl font-bold"; diff --git a/src/app/(public)/account/collections/[id]/page.tsx b/src/app/(public)/account/collections/[id]/page.tsx index 8e66704..787a815 100644 --- a/src/app/(public)/account/collections/[id]/page.tsx +++ b/src/app/(public)/account/collections/[id]/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/i18n/client"; import { notFound } from "next/navigation"; import { AppCard } from "@/components/app-card"; import { EmptyState } from "@/components/states"; diff --git a/src/app/(public)/account/collections/page.tsx b/src/app/(public)/account/collections/page.tsx index e139434..f5870cb 100644 --- a/src/app/(public)/account/collections/page.tsx +++ b/src/app/(public)/account/collections/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/i18n/client"; import { EmptyState } from "@/components/states"; import { ActionForm } from "@/components/ui/action-form"; import { Badge } from "@/components/ui/badge"; diff --git a/src/app/(public)/account/favorites/page.tsx b/src/app/(public)/account/favorites/page.tsx index 551e215..c2f9028 100644 --- a/src/app/(public)/account/favorites/page.tsx +++ b/src/app/(public)/account/favorites/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/i18n/client"; import { CardGrid } from "@/components/rail"; import { EmptyState } from "@/components/states"; import { db } from "@/server/db"; diff --git a/src/app/(public)/account/notifications/page.tsx b/src/app/(public)/account/notifications/page.tsx index e006e62..d0dbc26 100644 --- a/src/app/(public)/account/notifications/page.tsx +++ b/src/app/(public)/account/notifications/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/i18n/client"; import { Check, Trash2 } from "lucide-react"; import { EmptyState } from "@/components/states"; import { buttonClass } from "@/components/ui/button"; @@ -36,7 +36,7 @@ export default async function NotificationsPage() { return ( <>
-

Notifications{unread > 0 && {unread} unread}

+

Notifications{unread > 0 && {unread} unread}

{unread > 0 &&
}
{items.length === 0 ? New apps you may like, updates to apps you saved and replies to your reviews appear here. : ( diff --git a/src/app/(public)/account/reports/page.tsx b/src/app/(public)/account/reports/page.tsx index cadb7fe..4675627 100644 --- a/src/app/(public)/account/reports/page.tsx +++ b/src/app/(public)/account/reports/page.tsx @@ -17,7 +17,7 @@ export default async function MyReportsPage() { {r.targetType === "LISTING" ? r.listing?.name ?? "Listing" : r.targetType.toLowerCase()} · {r.reason.replace(/_/g, " ").toLowerCase()} {r.status.replace(/_/g, " ").toLowerCase()} - {formatDate(r.createdAt)} + {formatDate(r.createdAt)} ))} diff --git a/src/app/(public)/account/reviews/page.tsx b/src/app/(public)/account/reviews/page.tsx index d2d9be4..05f940d 100644 --- a/src/app/(public)/account/reviews/page.tsx +++ b/src/app/(public)/account/reviews/page.tsx @@ -1,4 +1,4 @@ -import Link from "next/link"; +import Link from "@/i18n/client"; import { EmptyState } from "@/components/states"; import { Badge } from "@/components/ui/badge"; import { formatDate } from "@/lib/labels"; @@ -23,7 +23,7 @@ export default async function MyReviewsPage() { {"★".repeat(r.rating)}{"☆".repeat(5 - r.rating)} {r.status !== "PUBLISHED" && {r.status === "HELD_FOR_MODERATION" ? "Awaiting moderation" : r.status.toLowerCase()}} {r.reply && Developer replied} - {formatDate(r.createdAt)} + {formatDate(r.createdAt)} {r.body &&

{r.body}

} {(r.status === "HIDDEN" || r.status === "REMOVED") && ( diff --git a/src/app/(public)/app/[slug]/alternatives/page.tsx b/src/app/(public)/app/[slug]/alternatives/page.tsx index c755b02..c239e52 100644 --- a/src/app/(public)/app/[slug]/alternatives/page.tsx +++ b/src/app/(public)/app/[slug]/alternatives/page.tsx @@ -1,5 +1,6 @@ +import { seoAlternates } from "@/server/i18n/seo"; import type { Metadata } from "next"; -import Link from "next/link"; +import Link from "@/i18n/client"; import { notFound } from "next/navigation"; import { CardGrid } from "@/components/rail"; import { EmptyState } from "@/components/states"; @@ -17,7 +18,7 @@ export async function generateMetadata({ params }: Props): Promise { return { title: `Alternatives to ${l.name}`, description: `Compare web apps similar to ${l.name}: competitors, free and open-source alternatives.`, - alternates: { canonical: `/app/${l.slug}/alternatives` }, + ...(await seoAlternates(`/app/${l.slug}/alternatives`, "listing")), robots: isSampleListing(l.slug) ? { index: false } : undefined, }; } diff --git a/src/app/(public)/app/[slug]/page.tsx b/src/app/(public)/app/[slug]/page.tsx index a6cf9b5..2e7d15e 100644 --- a/src/app/(public)/app/[slug]/page.tsx +++ b/src/app/(public)/app/[slug]/page.tsx @@ -1,5 +1,7 @@ +import { categoryNamer } from "@/server/i18n/categories"; +import { seoAlternates } from "@/server/i18n/seo"; import type { Metadata } from "next"; -import Link from "next/link"; +import Link from "@/i18n/client"; import { Ad } from "@/components/ads/ad"; import { notFound } from "next/navigation"; import { ArrowUpRight, BadgeCheck, CalendarCheck, ChevronRight, Globe, ShieldCheck, ShieldQuestion, Star, TriangleAlert, UserRound } from "lucide-react"; @@ -10,7 +12,7 @@ import { ShareButton } from "@/components/share-button"; import { Badge } from "@/components/ui/badge"; import { buttonClass } from "@/components/ui/button"; import { visitMilestone } from "@/lib/visits"; -import { AGE_LABEL, PLATFORM_LABEL, PRICING_LABEL, SECURITY_LABEL, VERIFICATION_LABEL, formatDate, isSampleListing } from "@/lib/labels"; +import { AGE_LABEL, PLATFORM_LABEL, PRICING_LABEL, SECURITY_LABEL, VERIFICATION_LABEL, isSampleListing } from "@/lib/labels"; import { displayDomain } from "@/lib/url"; import { enumArray, stringArray } from "@/lib/json-arrays"; import { Platform } from "@/generated/prisma/enums"; @@ -26,6 +28,8 @@ import { AddToCollection } from "@/components/community/add-to-collection"; import { ReviewsSection } from "@/components/community/reviews-section"; import { ViewTracker } from "@/components/community/view-tracker"; import { mediaUrl } from "@/server/storage"; +import { getLocale, getT } from "@/i18n/server"; +import { formatDateIn } from "@/i18n/format"; const PUBLIC_URL = () => (process.env.PUBLIC_ORIGIN || "http://localhost:3000").replace(/\/$/, ""); /** Absolute URL of public media (for crawlers and social previews). */ @@ -46,7 +50,7 @@ export async function generateMetadata({ params }: Props): Promise { return { title: `${listing.name} — ${category}`, description, - alternates: { canonical: `/app/${listing.slug}` }, + ...(await seoAlternates(`/app/${listing.slug}`, "listing")), openGraph: { type: "website", title: `${listing.name} — ${category}`, description, url: `/app/${listing.slug}`, ...(image ? { images: [{ url: image, alt: `${listing.name} ${shot!.kind === "LOGO" ? "logo" : "screenshot"}` }] } : {}) }, twitter: { card: shot?.kind === "SCREENSHOT" ? "summary_large_image" : "summary", title: listing.name, description, ...(image ? { images: [image] } : {}) }, robots: isSampleListing(listing.slug) ? { index: false } : undefined, @@ -57,7 +61,7 @@ function Fact({ label, children }: { label: string; children: React.ReactNode }) return (
{label}
-
{children}
+
{children}
); } @@ -89,6 +93,17 @@ export default async function AppPage({ params, searchParams }: Props) { const languages = stringArray(listing.languages); const verification = listing.developer ? VERIFICATION_LABEL[listing.developer.verificationLevel] : "Unclaimed listing"; const reportAction = submitListingReport.bind(null, listing.slug); + const [t, tc, locale] = await Promise.all([getT("store"), getT("common"), getLocale()]); + const catName = await categoryNamer(); + const formatDate = (d: Date | null | undefined) => (d ? formatDateIn(locale, d) : "—"); + // Developer-written text keeps its original language; it is marked so screen readers and + // translation tools know (the listing's first declared language, else English). + const contentLang = (languages[0] ?? "en").slice(0, 10); + // Brand safety: no ads on pages about blocked categories (Settings → Ad content policy) or 18+ apps. + const adContent = { + adult: listing.ageRating === "AGE_18_PLUS", + categorySlugs: [listing.primaryCategory?.slug, listing.primaryCategory?.parent?.slug, ...listing.categories.map(({ category }) => category.slug)].filter((x): x is string => Boolean(x)), + }; const logoKey = listing.media.find((m) => m.kind === "LOGO")?.asset.storageKey; const shotKeys = listing.media.filter((m) => m.kind === "SCREENSHOT").slice(0, 4).map((m) => m.asset.storageKey); @@ -114,9 +129,9 @@ export default async function AppPage({ params, searchParams }: Props) {