Files
co-lite/solvway-admin-portal/test/i18nCatalog.ts
T
ngqileandClaude Opus 5.5 5ee51d1913 chore: copy kept Tastefully modules and portals into Co-Lite
Backend modules from tastefully 8bd93d15: core-libs, core-session,
api-gateway, mobile-api, services-auth, services-system,
services-counter, services-member, services-log, services-email.
solvway-admin-portal from babyboo f64d096ea, solvway-customer-portal
from tastefully 8bd93d15. Copied as tracked files only.

Literal secrets replaced with environment placeholders:
- services-email: SMTP_PASSWORD, MAILGUN_API_KEY, SENDGRID_API_KEY,
  MAILJET_API_KEY, MAILJET_SECRET_KEY (optional, empty default)
- services-system: JUMIO_TOKEN, JUMIO_SECRET (optional)
- services-auth: USER_AUTH_API_SECRET (required); commented JWT secret removed
- core-libs: JWT_TOKEN default removed (required), XXL_JOB_TOKEN default
  removed, ipgeolocation key read from IPGEOLOCATION_API_KEY
- services-system EkycAppConfig: commented Jumio credentials removed

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
2026-11-26 15:55:45 +08:00

23 lines
1.4 KiB
TypeScript

import { DEFAULT_MESSAGES } from "@/app/lib/i18n/defaultMessages";
import { resolveMessage, type MessageParams } from "@/app/lib/i18n/t";
const placeholders = (code: string) => [...DEFAULT_MESSAGES[code].matchAll(/\{(\w+)\}/g)].map((m) => m[1]);
/** Every code renders as «Code», plus ":{param}" per placeholder in its English default, so a test can
* see both that the code was used and which values were passed: «ProductCountOther:3». */
export const CATALOG: Record<string, string> = Object.fromEntries(
Object.keys(DEFAULT_MESSAGES).map((code) => [code, `«${code}${placeholders(code).map((p) => `:{${p}}`).join("")}»`]),
);
/** The expected rendering of a code, values in the order the placeholders appear in the English default. */
export const m = (code: string, ...values: Array<string | number>) => `«${[code, ...values].join(":")}»`;
/** getServerT's replacement for vi.mock("@/app/lib/server/i18n"). */
export const serverT = async () => (code: string, params?: MessageParams) => resolveMessage(CATALOG, code, params);
/** A helper's `t` that renders the English defaults, for tests that assert the English text. */
export const tEn = (code: string, params?: MessageParams) => resolveMessage({}, code, params);
/** A helper's `t` that renders «Code» like CATALOG, for tests that assert which code was used. */
export const tCode = (code: string, params?: MessageParams) => resolveMessage(CATALOG, code, params);