From 62d25585e3829dde8ecbfb32546e808da7458956 Mon Sep 17 00:00:00 2001 From: JasonYv <233965174+JasonYv@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:24:38 -0800 Subject: [PATCH 01/38] build(deps): add Lingui 6.11.0 for the admin's interface languages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @lingui/core and @lingui/react at runtime; @lingui/vite-plugin, @lingui/cli and @lingui/format-po at build time. 6.11.0 rather than 6.12.0, which was ten days old. Registered in TECH_STACK.md §6 and §11.1 with licences, transitive count, install scripts (none) and the measured first-load delta. Decision D1 of docs/ADMIN_I18N_AND_UI.md. Co-Authored-By: Claude Opus 5.5 --- docs/TECH_STACK.md | 2 + package.json | 5 + pnpm-lock.yaml | 577 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 582 insertions(+), 2 deletions(-) diff --git a/docs/TECH_STACK.md b/docs/TECH_STACK.md index 8d07d92..8f3d43a 100644 --- a/docs/TECH_STACK.md +++ b/docs/TECH_STACK.md @@ -106,6 +106,7 @@ with **no vendor SDK entering the Worker**: | Build | `vite` + `@vitejs/plugin-react` | A build-time dependency only. The Babel transform signals needed is gone with them | | Markdown editing | `@codemirror/view`, `@codemirror/state`, `@codemirror/commands` and `@codemirror/lang-markdown` | The only body editor in 0.1. It runs in the browser and never enters the Worker | | Field forms | Generated in-repository from the declared fields, on `react-hook-form`; `zod` through `@hookform/resolvers` for the few forms with a fixed shape (sign-in, password, tokens, sender) | Content-kind fields, theme options, plugin settings and plugin panels are all schema-driven; no bespoke forms for them | +| Interface languages | `@lingui/core` + `@lingui/react` 6.11.0 at runtime; `@lingui/vite-plugin`, `@lingui/cli` and `@lingui/format-po` 6.11.0 at build time | Decided 2026-11-13 (`ADMIN_I18N_AND_UI.md`, D1). Messages are written as English in the source with `Trans` / `t` macros, extracted to `src/admin/locales/*.po` and compiled on import. Each catalog is its own chunk; the runtime adds 3.7 KiB to the first load (§8 of that document). `pnpm lint` runs `lingui check sync` and `lingui check missing --mode catalog`; a macro the transform did not replace fails the build (`vite.config.ts`) | Live preview | Reuses `src/core/` in the browser | Byte-identical to production | | Visual editing | `@tiptap/core` + `@tiptap/pm` (**0.2**) | Not in 0.1. Tiptap's DOM is never the truth about content | | Styling | Tailwind CSS 4 and shadcn/ui on Radix | Decided 2026-10-08 and done by 2026-11-03 (`ADMIN_MIGRATION.md`): every page is built from shadcn/ui components, and `styles.css` holds only the design tokens | @@ -199,6 +200,7 @@ received. | Package | Version | Licence | Layer | Transitive | Bundle delta (gzip) | Install scripts | Reason | | --- | --- | --- | --- | --- | --- | --- | --- | | `rehype-raw` | `7.0.0` | MIT | Render | 9 new: `entities` (BSD-2-Clause), `hast-util-from-parse5`, `hast-util-parse-selector`, `hast-util-raw`, `hast-util-to-parse5`, `hastscript`, `parse5`, `vfile-location`, `web-namespaces` (all MIT). None carry an `install`/`postinstall`/`preinstall` script | +53.2 KiB (Worker: 232.3 → 285.5 KiB gzip, 7.6% → 9.3% of Mallok's own 3 MiB render-path budget — not of a Cloudflare limit; theirs is 64 MiB uncompressed on either plan) | None, across all 10 packages | Gate B', settled 2026-09-02: makes `CONTENT_FORMAT §3.4`'s promise true — inline HTML is sanitised and kept, not dropped outright (`SECURITY.md §4`) | +| `@lingui/core`, `@lingui/react`, `@lingui/vite-plugin`, `@lingui/cli`, `@lingui/format-po` | `6.11.0` (released 2026-10-29; 6.12.0 was ten days old and not taken) | MIT | Admin (core, react) and build (the rest); all `devDependencies`, like the rest of the admin, because the admin ships as built assets | 58 new lockfile entries, 50 installed on any one machine: 8 of them are the other platforms' builds of `@lingui/native-tools`, a prebuilt Rust/SWC binary that runs the macro transform and the extractor at build time — the same kind of binary as `esbuild` and `rolldown`, never in the admin bundle or the Worker. Licences: 46 MIT, 2 Apache-2.0, 2 BSD-3-Clause | Admin first load +3.7 KiB (161.7 → 165.4 KiB gzip, budget 170). Worker: none — it does not import the admin (310.3 KiB gzip measured with this in) | None, across all 50 packages; pnpm 10 reported no build script | `ADMIN_I18N_AND_UI.md` D1: interface languages for the admin and the setup wizard, with ICU plurals and the English sentence kept in the source | Before this, the table had no rows: `fflate` was briefly added to unpack theme zips and removed when themes moved to build-time bundling (`tasks/TASK-04.md`). diff --git a/package.json b/package.json index e5e484e..0906be6 100644 --- a/package.json +++ b/package.json @@ -99,6 +99,11 @@ "@codemirror/view": "^6.43.9", "@hookform/resolvers": "5.9.1", "@lhci/cli": "0.15.1", + "@lingui/cli": "6.11.0", + "@lingui/core": "6.11.0", + "@lingui/format-po": "6.11.0", + "@lingui/react": "6.11.0", + "@lingui/vite-plugin": "6.11.0", "@playwright/test": "^1.63.0", "@tailwindcss/vite": "4.3.3", "@tanstack/react-query": "5.104.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ac9180c..689bbb2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -80,10 +80,25 @@ importers: version: 6.43.9 '@hookform/resolvers': specifier: 5.9.1 - version: 5.9.1(@standard-schema/spec@1.1.0)(ajv-formats@2.1.1(ajv@8.20.0))(ajv@8.20.0)(react-hook-form@7.89.0(@types/react@19.2.18)(react@19.2.8))(zod@4.4.3) + version: 5.9.1(@sinclair/typebox@0.27.12)(@standard-schema/spec@1.1.0)(ajv-formats@2.1.1(ajv@8.20.0))(ajv@8.20.0)(react-hook-form@7.89.0(@types/react@19.2.18)(react@19.2.8))(zod@4.4.3) '@lhci/cli': specifier: 0.15.1 version: 0.15.1 + '@lingui/cli': + specifier: 6.11.0 + version: 6.11.0(esbuild@0.28.1)(rolldown@1.2.6) + '@lingui/core': + specifier: 6.11.0 + version: 6.11.0(@babel/core@7.29.7) + '@lingui/format-po': + specifier: 6.11.0 + version: 6.11.0 + '@lingui/react': + specifier: 6.11.0 + version: 6.11.0(@babel/core@7.29.7)(react@19.2.8) + '@lingui/vite-plugin': + specifier: 6.11.0 + version: 6.11.0(@babel/core@7.29.7)(@lingui/babel-plugin-lingui-macro@6.11.0(@babel/core@7.29.7))(esbuild@0.28.1)(rolldown@1.2.6)(vite@8.2.2(@types/node@22.20.1)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0)) '@playwright/test': specifier: ^1.63.0 version: 1.63.0 @@ -479,6 +494,10 @@ packages: '@codemirror/view@6.43.9': resolution: {integrity: sha512-sTuUzTpPMFebRhg6dawChoKKgndIwfjmJgKVxBefPElcU2NwQ6AFroupk0SFqEerQyZOGRfDNnSN8Dw/lMAsXw==} + '@colors/colors@1.5.0': + resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} + engines: {node: '>=0.1.90'} + '@cspotcode/source-map-support@0.8.1': resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==} engines: {node: '>=12'} @@ -919,6 +938,14 @@ packages: cpu: [x64] os: [win32] + '@jest/schemas@29.6.3': + resolution: {integrity: sha512-mo5j5X+jIZmJQveBKeS/clAueipV7KgiX1vMgCxam1RNYiqE1w62n0/tJJnHtjW8ZHcQco5gY85jA3mi0L+nSA==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + '@jest/types@29.6.3': + resolution: {integrity: sha512-u3UPsIilWKOM3F9CXtrG8LEJmNxwoCQC/XVj4IKYXvvpx7QIi/Kg1LI5uDmDpKlac62NUtX7eLjRh+jVZcLOzw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + '@jridgewell/gen-mapping@0.3.13': resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==} @@ -966,9 +993,155 @@ packages: '@lhci/utils@0.15.1': resolution: {integrity: sha512-WclJnUQJeOMY271JSuaOjCv/aA0pgvuHZS29NFNdIeI14id8eiFsjith85EGKYhljgoQhJ2SiW4PsVfFiakNNw==} + '@lingui/babel-plugin-extract-messages@6.11.0': + resolution: {integrity: sha512-gKXMoLOJf91nVm959bn5AJCY5PdNXZjXP3ltKahhe1UjCZCMVQI8CTmt0bzEH8MlUm7/zXqqvME8dIAQTiNFYw==} + engines: {node: '>=22.19.0'} + + '@lingui/babel-plugin-lingui-macro@6.11.0': + resolution: {integrity: sha512-cFy6lJ8ZnvUowUuNoB5KSPUyT03lL9YNsFqeg7EbqHbzwcsT0uitIGc8pZ96+mwNq8RaACgd5amHcRfr18aAUQ==} + engines: {node: '>=22.19.0'} + peerDependencies: + '@babel/core': ^7.20.12 || ^8.0.0 + peerDependenciesMeta: + '@babel/core': + optional: true + + '@lingui/cli@6.11.0': + resolution: {integrity: sha512-R5qiCOAsV6STn+O3bWF+ttngLuh7Q+wf+83J34D0xDN/5pPAnYiek26rqGFwcpM9nAESzCEM0IoQsutpGCRLvg==} + engines: {node: '>=22.19.0'} + hasBin: true + peerDependencies: + esbuild: ^0.28.1 + rolldown: ^1.0.0 + peerDependenciesMeta: + esbuild: + optional: true + rolldown: + optional: true + + '@lingui/conf@6.11.0': + resolution: {integrity: sha512-2TYTmbXkecuUxFU0DaPrRF8slUCzEd+G3Wh0RXws/uP2RkakvrcMx+m+ZjdVHypT/3VyjIGsCfDpFSnlLppo+g==} + engines: {node: '>=22.19.0'} + + '@lingui/core@6.11.0': + resolution: {integrity: sha512-JQLQeUCu0MWxHbBjQbrRdoPQqD15tKLFpXMaXII60TsWnfeNhcqBVhL1c2U9VStIjlc3c9S2sMaieawahyMkwQ==} + engines: {node: '>=22.19.0'} + peerDependencies: + babel-plugin-macros: 2 || 3 + peerDependenciesMeta: + babel-plugin-macros: + optional: true + + '@lingui/format-po@6.11.0': + resolution: {integrity: sha512-XID3qLdPlxvM2nx+5cWtmAaCsxYFGBNe5xA5XHE4KRF0nG98BKN50M4577ntG3+cK+6G+0b5US4WLe1sdH65vw==} + engines: {node: '>=22.19.0'} + + '@lingui/message-utils@6.11.0': + resolution: {integrity: sha512-pRRELzVBQyXKhdFzhOi98hCfRDCHBhQmmCxraxrSkuthO+YD+4Xurap+9LiejAQqj1D2HAUxC+pEc7I9MPXfzQ==} + engines: {node: '>=22.19.0'} + + '@lingui/native-tools-android-arm64@0.2.0': + resolution: {integrity: sha512-8iBKJbVT83n6MAmeVCJDWaPqm69AHV8mjnY0hklH0SPP2V3rx8V4tLG7WLktg9qO++mbreYGmaHzIowwRwTgKQ==} + engines: {node: '>=22.19.0'} + cpu: [arm64] + os: [android] + + '@lingui/native-tools-darwin-arm64@0.2.0': + resolution: {integrity: sha512-NuJmNQjMOnMMvQgyUuN95/yER6Pspujav4xUm08WE3fKPTOZPIkB2TmOpBM2cVXhuDcsv5g+3x3tsnkwcd65DQ==} + engines: {node: '>=22.19.0'} + cpu: [arm64] + os: [darwin] + + '@lingui/native-tools-darwin-x64@0.2.0': + resolution: {integrity: sha512-n4G3GLcHKw5R56UzkKNFnm1ju/9nxBtPE40g+U+sUL4XUo6tPMX4J8b4yIE1dXYY6i5g7jQJm9Kvr/lIxibzOg==} + engines: {node: '>=22.19.0'} + cpu: [x64] + os: [darwin] + + '@lingui/native-tools-linux-arm64-gnu@0.2.0': + resolution: {integrity: sha512-vmb7cuTr/vyfn5kgyO/0JkCuru9r8DFAkgJLTUsbG12NL0ti/PN+lJeflplUFEcRiWZryvCJ6UFNtMw65WX9GQ==} + engines: {node: '>=22.19.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@lingui/native-tools-linux-arm64-musl@0.2.0': + resolution: {integrity: sha512-Y3gEixa7EFIozkFVMp2KKDWn5aGYzxCFPBgEB1EtVXHj+VyPewc/Oo7xvXORpqD9u4vZQzuOYQJh6G6UVL9wnQ==} + engines: {node: '>=22.19.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@lingui/native-tools-linux-x64-gnu@0.2.0': + resolution: {integrity: sha512-5gmB+mQt/DtenAm8KV2b2RihXZwce1SjF+E/lytQWGWfe/6JHl+kqBWOmrc3uhuB76xInyRw3ui4gDut5oAQYA==} + engines: {node: '>=22.19.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@lingui/native-tools-linux-x64-musl@0.2.0': + resolution: {integrity: sha512-Y6E+9ZgW5y+8OyzpEdCJc+waRhNHv2i0h4ulU6xX7/GOOPnb3QpmRvOd6aCXkg6HwOy5SNJ/Rm8drQRJKei6qg==} + engines: {node: '>=22.19.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + '@lingui/native-tools-win32-arm64-msvc@0.2.0': + resolution: {integrity: sha512-I/XzCL7eZaT4BSDMVKc+FBhCGPxecf1E0aR2YQshz9KMwmuubOfpqBw6ZjEEaggvZWO8cg+G0FP3v8U01m3JvQ==} + engines: {node: '>=22.19.0'} + cpu: [arm64] + os: [win32] + + '@lingui/native-tools-win32-x64-msvc@0.2.0': + resolution: {integrity: sha512-Po3MvSbHqzy8LhGDcCKrhQOOZL3PSBIct/fj5DpEkiP4+OrUocYbwX62AaV67ne/vzUTpYkEjALjq7ymSD14aA==} + engines: {node: '>=22.19.0'} + cpu: [x64] + os: [win32] + + '@lingui/native-tools@0.2.0': + resolution: {integrity: sha512-60zML3mPXI6bdMSTGO9r1cL0DWD1n7ajkOPGdaxl3oiHZc2Y9huEeftwtNYEvPXFLrDV+qt/F5mCqZEj1PFeQg==} + engines: {node: '>=22.19.0'} + peerDependencies: + '@lingui/conf': ^6.0.1 + + '@lingui/react@6.11.0': + resolution: {integrity: sha512-cHPALGiDeIeHOVOuBaYvgcs3ES4HuGSLM5DD4Q+RwneCP64gytHCoiSWhf8AfNySV7CxfNbtPSmuCqAP3NP+qA==} + engines: {node: '>=22.19.0'} + peerDependencies: + babel-plugin-macros: 2 || 3 + react: ^16.14.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + peerDependenciesMeta: + babel-plugin-macros: + optional: true + + '@lingui/vite-plugin@6.11.0': + resolution: {integrity: sha512-1+6ZxcfIV7dLZ2UscJaYaBd9+N2GecSKfR/v6MnZeCyt2+u2fETddZIBNTSyDPzGs65WHXBZ1WRSVklFZnAP3g==} + engines: {node: '>=22.19.0'} + peerDependencies: + '@babel/core': ^7.29.0 || ^8.0.0 + '@lingui/babel-plugin-lingui-macro': ^5 || ^6 + '@rolldown/plugin-babel': ^0.1.7 || ^0.2.0 + rolldown: ^1.0.0-rc.5 + vite: ^6.3.0 || ^7 || ^8 + peerDependenciesMeta: + '@babel/core': + optional: true + '@lingui/babel-plugin-lingui-macro': + optional: true + '@rolldown/plugin-babel': + optional: true + rolldown: + optional: true + '@marijn/find-cluster-break@1.0.4': resolution: {integrity: sha512-Wy0V7+SGUjnF9/TkiM1hKVDPj7jKXduPNboMVtHTA8dySMURWqfg/JZ9E2Sq8JgSJmkl7k7Qe9FLeMSrSraWmQ==} + '@messageformat/date-skeleton@1.1.0': + resolution: {integrity: sha512-rmGAfB1tIPER+gh3p/RgA+PVeRE/gxuQ2w4snFWPF5xtb5mbWR7Cbw7wCOftcUypbD6HVoxrVdyyghPm3WzP5A==} + + '@messageformat/parser@5.2.0': + resolution: {integrity: sha512-sc3hNZ0JtC32GhL5nUgPbh2ilcwji4G+Vmj/vhMd8hZaH//NDOvkfwKK1mFnRWG5h2DpksN8xr/HB5/+vMg3iw==} + '@modelcontextprotocol/core@2.4.0': resolution: {integrity: sha512-z8QBKqdfXLPzkLQuG4xp8hrVEMm1PZ1IgxMN2sMbJiFiAKOWXnAzogXn2W4aqIBlP1ea6U5yiqVquvUNM1Cj6Q==} engines: {node: '>=20'} @@ -977,6 +1150,10 @@ packages: resolution: {integrity: sha512-rgR9yxSaAJ+bcsi/XroT/S2AfPiIWloXAnrdfYSCms9ivVju0ishu/wW0J21Ho6+ZOR1r7RyeRbjiRuF87ix5Q==} engines: {node: '>=20'} + '@noble/hashes@2.4.0': + resolution: {integrity: sha512-X5XaVWZIBCT7HHZGm5I7ZQXDwLG+bGXuSrMQAW+7Zvl87h1kmc1ZB1VSRJcpUfoUrGQp4Fkoxm5kZ+Ms+aW+eA==} + engines: {node: '>= 20.19.0'} + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1837,6 +2014,9 @@ packages: resolution: {integrity: sha512-wMvZ3DGdnhCwtpeFbwKybSGfCcP52bZX77jMKgZvupmirgyA5KRLlkeQXkI2RGHIaD8TX2iWe2wcIEjjqzg2FQ==} engines: {node: '>=20.18.1'} + '@sinclair/typebox@0.27.12': + resolution: {integrity: sha512-hhyNJ+nbR6ZR7pToHvllEFun9TL0sbL+tk/ON75lo+Xas054uez98qRbsuNt7MBCyZKK4+8Yli/OAGZhmfBZ/g==} + '@sindresorhus/is@7.2.0': resolution: {integrity: sha512-P1Cz1dWaFfR4IR+U13mqqiGsLFf1KbayybWwdd2vfctdV6hDpUkgCY0nKOLLTMSoRd/jJNjtbqzf13K8DCCXQw==} engines: {node: '>=18'} @@ -1854,6 +2034,12 @@ packages: '@standard-schema/utils@0.3.0': resolution: {integrity: sha512-e7Mew686owMaPJVNNLs55PUvgz371nKgwsc4vxE49zsODpJEnxgxRo2y/OKrqueavXgZNMDVj3DdHFlaSAeU8g==} + '@swc/counter@0.1.3': + resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} + + '@swc/types@0.1.28': + resolution: {integrity: sha512-V6Mnml8v09QALx6K0elJ7o9K/MkVDtW3t6L+7Ou/JcWtb3xwId2AH4FeOceySd2JaO87IMw4+6vSZxLm34LPbw==} + '@tailwindcss/node@4.3.3': resolution: {integrity: sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg==} @@ -1981,6 +2167,15 @@ packages: '@types/hast@3.0.5': resolution: {integrity: sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==} + '@types/istanbul-lib-coverage@2.0.6': + resolution: {integrity: sha512-2QF/t/auWm0lsy8XtKVPG19v3sSOQlJe/YHZgfjb/KBBHOGSV+J2q/S671rcq9uTBrLAXmZpqJiaQbMT+zNU1w==} + + '@types/istanbul-lib-report@3.0.3': + resolution: {integrity: sha512-NQn7AHQnk/RSLOxrBbGyJM/aVQ+pjj5HCgasFxc0K/KhoATfQ/47AyUl15I2yBUpihjmas+a+VJBOqecrFH+uA==} + + '@types/istanbul-reports@3.0.4': + resolution: {integrity: sha512-pk2B1NWalF9toCRu6gjBzR69syFjP4Od8WRAX+0mmf9lAjCRicLOWc+ZrxZHx/0XRjotgkF9t6iaMJ+aXcOdZQ==} + '@types/mdast@4.0.4': resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==} @@ -2013,6 +2208,12 @@ packages: '@types/whatwg-mimetype@3.0.2': resolution: {integrity: sha512-c2AKvDT8ToxLIOUlN51gTiHXflsfIFisS4pO7pDPoKouJCESkhZnEy623gwP9laCy5lnLDAw1vAzu2vM2YLOrA==} + '@types/yargs-parser@21.0.3': + resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} + + '@types/yargs@17.0.35': + resolution: {integrity: sha512-qUHkeCyQFxMXg79wQfTtfndEC+N9ZZg76HJftDJp+qH2tV7Gj4OJi7l+PiWwJ+pWtW8GwSmqsDj/oymhrTWXjg==} + '@types/yauzl@2.10.3': resolution: {integrity: sha512-oJoftv0LSuaDZE3Le4DbKX+KS9G36NzOeSap90UIK0yMA/NhKJhqlSGtNDORNRaIbQfzjXDrQa0ytJ6mNRGz/Q==} @@ -2124,6 +2325,10 @@ packages: resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} engines: {node: '>=8'} + ansi-styles@5.2.0: + resolution: {integrity: sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==} + engines: {node: '>=10'} + argparse@1.0.10: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} @@ -2267,6 +2472,10 @@ packages: resolution: {integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==} engines: {node: '>=6'} + camelcase@6.3.0: + resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} + engines: {node: '>=10'} + caniuse-lite@1.0.30001820: resolution: {integrity: sha512-gfWD6MxqVCqAOwmODfZf7DchWvlrA+SRdNX7ceLfg3xRqe5ssjjpF7EgslC/0tiLiNTajdaNN/q8c/5u/7Gz8w==} @@ -2281,6 +2490,10 @@ packages: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} + chalk@4.1.2: + resolution: {integrity: sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==} + engines: {node: '>=10'} + chalk@5.6.2: resolution: {integrity: sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==} engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} @@ -2297,6 +2510,10 @@ packages: chardet@0.7.0: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} + chokidar@5.0.0: + resolution: {integrity: sha512-TQMmc3w+5AxjpL8iIiwebF73dRDF4fBIieAqGn9RGCWaEVwQ6Fb2cGe31Yns0RRIzii5goJ1Y7xbMwo1TxMplw==} + engines: {node: '>= 20.19.0'} + chrome-launcher@0.13.4: resolution: {integrity: sha512-nnzXiDbGKjDSK6t2I+35OAPBy5Pw/39bgkb/ZAFwMhwJbdYBp6aH+vW28ZgtjdU890Q7D+3wN/tB8N66q5Gi2A==} @@ -2328,6 +2545,14 @@ packages: resolution: {integrity: sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==} engines: {node: '>=6'} + cli-spinners@3.4.0: + resolution: {integrity: sha512-bXfOC4QcT1tKXGorxL3wbJm6XJPDqEnij2gQ2m7ESQuE+/z9YFIWnl/5RpTiKWbMq3EVKR4fRLJGn6DVfu0mpw==} + engines: {node: '>=18.20'} + + cli-table3@0.6.5: + resolution: {integrity: sha512-+W/5efTR7y5HRD7gACw9yQjqMVvEMLBHmboM/kPWam+H+Hmyrgjh6YncVKK122YZkXrLudzTuAukUw9FnMf7IQ==} + engines: {node: 10.* || >= 12.*} + cli-width@2.2.1: resolution: {integrity: sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==} @@ -2379,6 +2604,10 @@ packages: resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} engines: {node: '>=16'} + commander@13.1.0: + resolution: {integrity: sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==} + engines: {node: '>=18'} + commander@14.0.3: resolution: {integrity: sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw==} engines: {node: '>=20'} @@ -3062,6 +3291,14 @@ packages: resolution: {integrity: sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==} engines: {node: '>=8'} + jest-get-type@29.6.3: + resolution: {integrity: sha512-zrteXnqYxfQh7l5FHyL38jL39di8H8rHoecLH3JNxH3BwOrBsNeabdap5e0I23lD4HHI8W5VFBZqG4Eaq5LNcw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + + jest-validate@29.7.0: + resolution: {integrity: sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + jiti@2.7.0: resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==} hasBin: true @@ -3113,6 +3350,10 @@ packages: legacy-javascript@0.0.4: resolution: {integrity: sha512-UTmeKBVxnfJcpmpOvzzNnLsQT99BXHpPlc/ZKddIRmWmrR0fw6335I3lq4+sJoP60UTbBNaYsGYVPc65YB1x3A==} + leven@3.1.0: + resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==} + engines: {node: '>=6'} + lie@3.1.1: resolution: {integrity: sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==} @@ -3278,6 +3519,10 @@ packages: resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} engines: {node: '>= 12.0.0'} + lilconfig@3.1.5: + resolution: {integrity: sha512-aRAOI9Ia43ygL4o1EOmC/sc/0OFxrm7qcQngiIyWaqVnSnz932ybJ07zyCcgMNGSDP8Yxaf88Xj1zHEXmvQ4SA==} + engines: {node: '>=14'} + liquidjs@10.29.0: resolution: {integrity: sha512-pCVOhs6FLAR8su3ItJ07diN26t6W5dHQRnmTMy8HPyTFuv1+oSCVJIGp5pGjfQyOZfh50KswvKtMTp6p4JEIdw==} engines: {node: '>=16'} @@ -3304,6 +3549,10 @@ packages: resolution: {integrity: sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==} engines: {node: '>=18'} + log-symbols@7.0.1: + resolution: {integrity: sha512-ja1E3yCr9i/0hmBVaM0bfwDjnGy8I/s6PP4DFp+yP+a+mrHO4Rm7DtmnqROTUkHIkqffC84YY7AeqX6oFk0WFg==} + engines: {node: '>=18'} + longest-streak@3.1.0: resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==} @@ -3549,6 +3798,9 @@ packages: resolution: {integrity: sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==} hasBin: true + moo@0.5.3: + resolution: {integrity: sha512-m2fmM2dDm7GZQsY7KK2cme8agi+AAljILjQnof7p1ZMDe6dQ4bdnSMx0cPppudoeNv5hEFQirN6u+O4fDE0IWA==} + ms@2.0.0: resolution: {integrity: sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==} @@ -3588,6 +3840,10 @@ packages: resolution: {integrity: sha512-6li2QanLsAXpIH2R6j77MzRyvOyrvdTqlKtO4CgBdHGNvN99ZZfyxszHc5o5+IZBWD5u6Hzwg83JoGXmqZNG9Q==} engines: {node: '>=18'} + normalize-path@3.0.0: + resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} + engines: {node: '>=0.10.0'} + npm-run-path@4.0.1: resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} engines: {node: '>=8'} @@ -3647,6 +3903,10 @@ packages: resolution: {integrity: sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw==} engines: {node: '>=18'} + ora@9.4.1: + resolution: {integrity: sha512-6VlU9MLXbjVQD04AZCMX28hVtA5bUoadvUqO76MUCVA0ilwJbMiHsITRPfyVm6p/BC0Av/BXMujx39WCe1LEqw==} + engines: {node: '>=20'} + os-tmpdir@1.0.2: resolution: {integrity: sha512-D2FR03Vir7FIu45XBY20mTb+/ZSWB00sjU9jdQXt83gDrI4Ztz5Fs7/yy74g2N5SVQY4xY1qDr4rNddwYRVX0g==} engines: {node: '>=0.10.0'} @@ -3749,6 +4009,10 @@ packages: engines: {node: '>=20'} hasBin: true + pofile-ts@4.0.3: + resolution: {integrity: sha512-sz1pnjgEfPyZ+QvaeX3NtCmbYnEvG01LZRLoN/uXoLtPZtxCIH5IctL7yXXc0fFyk/fqV6K8g3hlNfr6IJwupA==} + engines: {node: '>=20'} + postcss-selector-parser@7.1.7: resolution: {integrity: sha512-wWBro/7hJ40ye6TPiXkUQoXKCw23xSsjriUvqd7Uls9Sso3oLiON1flc18cCdnjgCRXw4fBVqUJJeOdDTh3P3g==} engines: {node: '>=4'} @@ -3761,6 +4025,10 @@ packages: resolution: {integrity: sha512-C+y9x90UElAddDZmV4qOx9W53B61PO7cIqWz2dQsWlwswuq4mr8NEwytdGKboYbQlGZ3awrkTeNvcZiZNHnQ8A==} engines: {node: '>=20'} + pretty-format@29.7.0: + resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} + engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + pretty-ms@9.3.1: resolution: {integrity: sha512-HzMy3Geq23nVALD/M2LliU+F+M+gVNsvkQWWqeBZ8HDiCgzo6YPJ/Omrmtq24EFrIsk0a3EkQGEd7bDOo+IhGA==} engines: {node: '>=18'} @@ -3787,6 +4055,11 @@ packages: proxy-from-env@1.1.0: resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==} + pseudolocale@3.1.0: + resolution: {integrity: sha512-jBidehQu5WO8zbFUod0ETJYoVPxZ0ixsdI9B8ilkE0eA+YTydxHA7ujNdU4YhTexD5yH5Griv9r5CuXx+nwFUA==} + engines: {node: '>=24.0.0'} + hasBin: true + pump@3.0.4: resolution: {integrity: sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==} @@ -3841,6 +4114,9 @@ packages: '@types/react': optional: true + react-is@18.3.1: + resolution: {integrity: sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==} + react-remove-scroll-bar@2.3.8: resolution: {integrity: sha512-9r+yi9+mgU33AKcj6IbT9oRCO78WriSj6t/cF8DWBZJ9aOGPOTEDvdUDz1FwKim7QXWwmHqtdHnRJfhAxEG46Q==} engines: {node: '>=10'} @@ -3891,6 +4167,10 @@ packages: resolution: {integrity: sha512-PWaYA1L/q9u2u7xYQi+Y3L3Yfnie7XyLeaJICV1MGD6LprsBxcAqGjYyr0eY3p+QdsA+x/Irkt4Qif8D63+Sbw==} engines: {node: '>=0.10.0'} + readdirp@5.1.1: + resolution: {integrity: sha512-Kko+Y5XQ6fM+Ce3dq3m9YGxnacYZYl9cA1wZjaF3Vbry2L3i1qVg8+CAgNPsXRArPMUMCaOR7oa9Nqntc43JKA==} + engines: {node: '>= 20.19.0'} + recast@0.23.21: resolution: {integrity: sha512-mFAyJq9vUbSTARLZUvAEf1z3YxlvAwswbmxMx2mPA/MSm4KmpwvwvhsH/NIrZhyOuwD60Lzyw2qh83uCbgTPYw==} engines: {node: '>= 4'} @@ -4095,6 +4375,10 @@ packages: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + source-map@0.7.6: + resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==} + engines: {node: '>= 12'} + space-separated-tokens@2.0.2: resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} @@ -4119,6 +4403,10 @@ packages: resolution: {integrity: sha512-UhDfHmA92YAlNnCfhmq0VeNL5bDbiZGg7sZ2IvPsXubGkiNa9EC+tUTsjBRsYUAz87btI6/1wf4XoVvQ3uRnmQ==} engines: {node: '>=18'} + stdin-discarder@0.3.2: + resolution: {integrity: sha512-eCPu1qRxPVkl5605OTWF8Wz40b4Mf45NY5LQmVPQ599knfs5QhASUm9GbJ5BDMDOXgrnh0wyEdvzmL//YMlw0A==} + engines: {node: '>=18'} + streamx@2.28.1: resolution: {integrity: sha512-zEzXb0s5Cds7tqMH6rhZ05lcJydCWiQPEwiNngVqzsxCc962vLY4Uw+mW7od8kDH258k2Uz/JrOkdIAAhSh9VA==} @@ -4134,6 +4422,10 @@ packages: resolution: {integrity: sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==} engines: {node: '>=18'} + string-width@8.3.0: + resolution: {integrity: sha512-ZbmZM0JCihQN91dWnxoipT2KOEyHqEyfRXUyjuRhW8b/xnqPDoq4gWEVApTVa9db2wN8mmoikgFBbjh71+cGeQ==} + engines: {node: '>=20'} + stringify-entities@4.0.4: resolution: {integrity: sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==} @@ -4232,6 +4524,10 @@ packages: resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} engines: {node: '>=12.0.0'} + tinypool@2.2.0: + resolution: {integrity: sha512-jBrmx4lYmaC9k/mgPbylxs7kBUxHtD8256up+HjLaDFfXScKJQyil+SWXSvhAtT7XHo+yTVlpB81PGmHP8oLSQ==} + engines: {node: ^20.0.0 || >=22.0.0} + tinyrainbow@3.1.1: resolution: {integrity: sha512-yau8yJdTt989Mm0Bd/236QnzEiPf2xLLTqUZRUJOo/3CB078LSwzei343DgtJVmfJKJE3TMINY1u42SQsP6mXw==} engines: {node: '>=14.0.0'} @@ -4380,6 +4676,11 @@ packages: '@types/react': optional: true + use-sync-external-store@1.7.0: + resolution: {integrity: sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A==} + peerDependencies: + react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 + util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} @@ -5036,6 +5337,9 @@ snapshots: style-mod: 4.1.3 w3c-keyname: 2.2.8 + '@colors/colors@1.5.0': + optional: true + '@cspotcode/source-map-support@0.8.1': dependencies: '@jridgewell/trace-mapping': 0.3.9 @@ -5187,11 +5491,12 @@ snapshots: dependencies: tslib: 2.8.1 - '@hookform/resolvers@5.9.1(@standard-schema/spec@1.1.0)(ajv-formats@2.1.1(ajv@8.20.0))(ajv@8.20.0)(react-hook-form@7.89.0(@types/react@19.2.18)(react@19.2.8))(zod@4.4.3)': + '@hookform/resolvers@5.9.1(@sinclair/typebox@0.27.12)(@standard-schema/spec@1.1.0)(ajv-formats@2.1.1(ajv@8.20.0))(ajv@8.20.0)(react-hook-form@7.89.0(@types/react@19.2.18)(react@19.2.8))(zod@4.4.3)': dependencies: '@standard-schema/utils': 0.3.0 react-hook-form: 7.89.0(@types/react@19.2.18)(react@19.2.8) optionalDependencies: + '@sinclair/typebox': 0.27.12 '@standard-schema/spec': 1.1.0 ajv: 8.20.0 ajv-formats: 2.1.1(ajv@8.20.0) @@ -5303,6 +5608,19 @@ snapshots: '@img/sharp-win32-x64@0.35.4': optional: true + '@jest/schemas@29.6.3': + dependencies: + '@sinclair/typebox': 0.27.12 + + '@jest/types@29.6.3': + dependencies: + '@jest/schemas': 29.6.3 + '@types/istanbul-lib-coverage': 2.0.6 + '@types/istanbul-reports': 3.0.4 + '@types/node': 22.20.1 + '@types/yargs': 17.0.35 + chalk: 4.1.2 + '@jridgewell/gen-mapping@0.3.13': dependencies: '@jridgewell/sourcemap-codec': 1.6.0 @@ -5402,8 +5720,148 @@ snapshots: - supports-color - utf-8-validate + '@lingui/babel-plugin-extract-messages@6.11.0': + dependencies: + '@lingui/conf': 6.11.0 + + '@lingui/babel-plugin-lingui-macro@6.11.0(@babel/core@7.29.7)': + dependencies: + '@lingui/conf': 6.11.0 + '@lingui/message-utils': 6.11.0 + optionalDependencies: + '@babel/core': 7.29.7 + + '@lingui/cli@6.11.0(esbuild@0.28.1)(rolldown@1.2.6)': + dependencies: + '@babel/core': 7.29.7 + '@babel/generator': 7.29.12 + '@babel/parser': 7.29.12 + '@babel/types': 7.29.11 + '@lingui/babel-plugin-extract-messages': 6.11.0 + '@lingui/babel-plugin-lingui-macro': 6.11.0(@babel/core@7.29.7) + '@lingui/conf': 6.11.0 + '@lingui/core': 6.11.0(@babel/core@7.29.7) + '@lingui/format-po': 6.11.0 + '@lingui/message-utils': 6.11.0 + '@lingui/native-tools': 0.2.0(@lingui/conf@6.11.0) + chokidar: 5.0.0 + cli-table3: 0.6.5 + commander: 14.0.3 + jiti: 2.7.0 + micromatch: 4.0.8 + ms: 2.1.3 + normalize-path: 3.0.0 + ora: 9.4.1 + pseudolocale: 3.1.0 + source-map: 0.7.6 + tinypool: 2.2.0 + optionalDependencies: + esbuild: 0.28.1 + rolldown: 1.2.6 + transitivePeerDependencies: + - babel-plugin-macros + - supports-color + + '@lingui/conf@6.11.0': + dependencies: + jest-validate: 29.7.0 + jiti: 2.7.0 + lilconfig: 3.1.5 + normalize-path: 3.0.0 + + '@lingui/core@6.11.0(@babel/core@7.29.7)': + dependencies: + '@lingui/babel-plugin-lingui-macro': 6.11.0(@babel/core@7.29.7) + '@lingui/message-utils': 6.11.0 + transitivePeerDependencies: + - '@babel/core' + + '@lingui/format-po@6.11.0': + dependencies: + '@lingui/conf': 6.11.0 + '@lingui/message-utils': 6.11.0 + pofile-ts: 4.0.3 + + '@lingui/message-utils@6.11.0': + dependencies: + '@messageformat/date-skeleton': 1.1.0 + '@messageformat/parser': 5.2.0 + '@noble/hashes': 2.4.0 + + '@lingui/native-tools-android-arm64@0.2.0': + optional: true + + '@lingui/native-tools-darwin-arm64@0.2.0': + optional: true + + '@lingui/native-tools-darwin-x64@0.2.0': + optional: true + + '@lingui/native-tools-linux-arm64-gnu@0.2.0': + optional: true + + '@lingui/native-tools-linux-arm64-musl@0.2.0': + optional: true + + '@lingui/native-tools-linux-x64-gnu@0.2.0': + optional: true + + '@lingui/native-tools-linux-x64-musl@0.2.0': + optional: true + + '@lingui/native-tools-win32-arm64-msvc@0.2.0': + optional: true + + '@lingui/native-tools-win32-x64-msvc@0.2.0': + optional: true + + '@lingui/native-tools@0.2.0(@lingui/conf@6.11.0)': + dependencies: + '@lingui/conf': 6.11.0 + '@swc/types': 0.1.28 + optionalDependencies: + '@lingui/native-tools-android-arm64': 0.2.0 + '@lingui/native-tools-darwin-arm64': 0.2.0 + '@lingui/native-tools-darwin-x64': 0.2.0 + '@lingui/native-tools-linux-arm64-gnu': 0.2.0 + '@lingui/native-tools-linux-arm64-musl': 0.2.0 + '@lingui/native-tools-linux-x64-gnu': 0.2.0 + '@lingui/native-tools-linux-x64-musl': 0.2.0 + '@lingui/native-tools-win32-arm64-msvc': 0.2.0 + '@lingui/native-tools-win32-x64-msvc': 0.2.0 + + '@lingui/react@6.11.0(@babel/core@7.29.7)(react@19.2.8)': + dependencies: + '@lingui/babel-plugin-lingui-macro': 6.11.0(@babel/core@7.29.7) + '@lingui/core': 6.11.0(@babel/core@7.29.7) + react: 19.2.8 + use-sync-external-store: 1.7.0(react@19.2.8) + transitivePeerDependencies: + - '@babel/core' + + '@lingui/vite-plugin@6.11.0(@babel/core@7.29.7)(@lingui/babel-plugin-lingui-macro@6.11.0(@babel/core@7.29.7))(esbuild@0.28.1)(rolldown@1.2.6)(vite@8.2.2(@types/node@22.20.1)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0))': + dependencies: + '@lingui/cli': 6.11.0(esbuild@0.28.1)(rolldown@1.2.6) + '@lingui/conf': 6.11.0 + '@lingui/native-tools': 0.2.0(@lingui/conf@6.11.0) + vite: 8.2.2(@types/node@22.20.1)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.0) + optionalDependencies: + '@babel/core': 7.29.7 + '@lingui/babel-plugin-lingui-macro': 6.11.0(@babel/core@7.29.7) + rolldown: 1.2.6 + transitivePeerDependencies: + - babel-plugin-macros + - esbuild + - supports-color + '@marijn/find-cluster-break@1.0.4': {} + '@messageformat/date-skeleton@1.1.0': {} + + '@messageformat/parser@5.2.0': + dependencies: + moo: 0.5.3 + '@modelcontextprotocol/core@2.4.0': dependencies: zod: 4.4.3 @@ -5413,6 +5871,8 @@ snapshots: '@modelcontextprotocol/core': 2.4.0 zod: 4.4.3 + '@noble/hashes@2.4.0': {} + '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -6326,6 +6786,8 @@ snapshots: transitivePeerDependencies: - supports-color + '@sinclair/typebox@0.27.12': {} + '@sindresorhus/is@7.2.0': {} '@sindresorhus/merge-streams@4.0.0': {} @@ -6336,6 +6798,12 @@ snapshots: '@standard-schema/utils@0.3.0': {} + '@swc/counter@0.1.3': {} + + '@swc/types@0.1.28': + dependencies: + '@swc/counter': 0.1.3 + '@tailwindcss/node@4.3.3': dependencies: '@jridgewell/remapping': 2.3.5 @@ -6438,6 +6906,16 @@ snapshots: dependencies: '@types/unist': 3.0.3 + '@types/istanbul-lib-coverage@2.0.6': {} + + '@types/istanbul-lib-report@3.0.3': + dependencies: + '@types/istanbul-lib-coverage': 2.0.6 + + '@types/istanbul-reports@3.0.4': + dependencies: + '@types/istanbul-lib-report': 3.0.3 + '@types/mdast@4.0.4': dependencies: '@types/unist': 3.0.3 @@ -6468,6 +6946,12 @@ snapshots: '@types/whatwg-mimetype@3.0.2': {} + '@types/yargs-parser@21.0.3': {} + + '@types/yargs@17.0.35': + dependencies: + '@types/yargs-parser': 21.0.3 + '@types/yauzl@2.10.3': dependencies: '@types/node': 22.20.1 @@ -6573,6 +7057,8 @@ snapshots: dependencies: color-convert: 2.0.1 + ansi-styles@5.2.0: {} + argparse@1.0.10: dependencies: sprintf-js: 1.0.3 @@ -6704,6 +7190,8 @@ snapshots: camelcase@5.3.1: {} + camelcase@6.3.0: {} + caniuse-lite@1.0.30001820: {} ccount@2.0.1: {} @@ -6716,6 +7204,11 @@ snapshots: escape-string-regexp: 1.0.5 supports-color: 5.5.0 + chalk@4.1.2: + dependencies: + ansi-styles: 4.3.0 + supports-color: 7.2.0 + chalk@5.6.2: {} character-entities-html4@2.1.0: {} @@ -6726,6 +7219,10 @@ snapshots: chardet@0.7.0: {} + chokidar@5.0.0: + dependencies: + readdirp: 5.1.1 + chrome-launcher@0.13.4: dependencies: '@types/node': 22.20.1 @@ -6768,6 +7265,14 @@ snapshots: cli-spinners@2.9.2: {} + cli-spinners@3.4.0: {} + + cli-table3@0.6.5: + dependencies: + string-width: 4.2.3 + optionalDependencies: + '@colors/colors': 1.5.0 + cli-width@2.2.1: {} cliui@6.0.0: @@ -6808,6 +7313,8 @@ snapshots: commander@11.1.0: {} + commander@13.1.0: {} + commander@14.0.3: {} compressible@2.0.18: @@ -7539,6 +8046,17 @@ snapshots: html-escaper: 2.0.2 istanbul-lib-report: 3.0.1 + jest-get-type@29.6.3: {} + + jest-validate@29.7.0: + dependencies: + '@jest/types': 29.6.3 + camelcase: 6.3.0 + chalk: 4.1.2 + jest-get-type: 29.6.3 + leven: 3.1.0 + pretty-format: 29.7.0 + jiti@2.7.0: {} jpeg-js@0.4.4: {} @@ -7574,6 +8092,8 @@ snapshots: legacy-javascript@0.0.4: {} + leven@3.1.0: {} + lie@3.1.1: dependencies: immediate: 3.0.6 @@ -7730,6 +8250,8 @@ snapshots: lightningcss-win32-arm64-msvc: 1.33.0 lightningcss-win32-x64-msvc: 1.33.0 + lilconfig@3.1.5: {} + liquidjs@10.29.0: dependencies: commander: 10.0.1 @@ -7756,6 +8278,11 @@ snapshots: chalk: 5.6.2 is-unicode-supported: 1.3.0 + log-symbols@7.0.1: + dependencies: + is-unicode-supported: 2.1.0 + yoctocolors: 2.2.0 + longest-streak@3.1.0: {} lookup-closest-locale@6.2.0: {} @@ -8165,6 +8692,8 @@ snapshots: dependencies: minimist: 1.2.8 + moo@0.5.3: {} + ms@2.0.0: {} ms@2.1.3: {} @@ -8185,6 +8714,8 @@ snapshots: node-releases@2.0.63: {} + normalize-path@3.0.0: {} + npm-run-path@4.0.1: dependencies: path-key: 3.1.1 @@ -8254,6 +8785,17 @@ snapshots: string-width: 7.2.0 strip-ansi: 7.2.0 + ora@9.4.1: + dependencies: + chalk: 5.6.2 + cli-cursor: 5.0.0 + cli-spinners: 3.4.0 + is-interactive: 2.0.0 + is-unicode-supported: 2.1.0 + log-symbols: 7.0.1 + stdin-discarder: 0.3.2 + string-width: 8.3.0 + os-tmpdir@1.0.2: {} p-limit@2.3.0: @@ -8334,6 +8876,8 @@ snapshots: dependencies: playwright-core: 1.63.0 + pofile-ts@4.0.3: {} + postcss-selector-parser@7.1.7: dependencies: cssesc: 3.0.0 @@ -8347,6 +8891,12 @@ snapshots: powershell-utils@0.2.1: {} + pretty-format@29.7.0: + dependencies: + '@jest/schemas': 29.6.3 + ansi-styles: 5.2.0 + react-is: 18.3.1 + pretty-ms@9.3.1: dependencies: parse-ms: 4.0.0 @@ -8380,6 +8930,10 @@ snapshots: proxy-from-env@1.1.0: {} + pseudolocale@3.1.0: + dependencies: + commander: 13.1.0 + pump@3.0.4: dependencies: end-of-stream: 1.4.5 @@ -8497,6 +9051,8 @@ snapshots: optionalDependencies: '@types/react': 19.2.18 + react-is@18.3.1: {} + react-remove-scroll-bar@2.3.8(@types/react@19.2.18)(react@19.2.8): dependencies: react: 19.2.8 @@ -8536,6 +9092,8 @@ snapshots: react@19.2.8: {} + readdirp@5.1.1: {} + recast@0.23.21: dependencies: ast-types: 0.16.3 @@ -8840,6 +9398,8 @@ snapshots: source-map@0.6.1: {} + source-map@0.7.6: {} + space-separated-tokens@2.0.2: {} speedline-core@1.4.3: @@ -8858,6 +9418,8 @@ snapshots: stdin-discarder@0.2.2: {} + stdin-discarder@0.3.2: {} + streamx@2.28.1: dependencies: events-universal: 1.0.1 @@ -8884,6 +9446,11 @@ snapshots: get-east-asian-width: 1.7.0 strip-ansi: 7.2.0 + string-width@8.3.0: + dependencies: + get-east-asian-width: 1.7.0 + strip-ansi: 7.2.0 + stringify-entities@4.0.4: dependencies: character-entities-html4: 2.1.0 @@ -8988,6 +9555,8 @@ snapshots: fdir: 6.5.0(picomatch@4.0.7) picomatch: 4.0.7 + tinypool@2.2.0: {} + tinyrainbow@3.1.1: {} tldts-core@6.1.86: {} @@ -9124,6 +9693,10 @@ snapshots: optionalDependencies: '@types/react': 19.2.18 + use-sync-external-store@1.7.0(react@19.2.8): + dependencies: + react: 19.2.8 + util-deprecate@1.0.2: {} utils-merge@1.0.1: {} From a635c357e11d044d310b3cfa97d3a838d43c7c81 Mon Sep 17 00:00:00 2001 From: JasonYv <233965174+JasonYv@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:24:38 -0800 Subject: [PATCH 02/38] feat(admin): choose the interface language, and translate the shell and sign-in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The admin resolves its interface language before the first render: the choice kept in this browser, else the first of the browser's languages it has a catalog for, else English. The account menu gains "Interface language", listing English and 简体中文 in their own names; switching re-renders in place and sets . No cookie is set. Messages stay English in the source behind Lingui's macros and are extracted to src/admin/locales/*.po, each catalog a chunk of its own. `pnpm lint` now fails on a missing translation or a stale catalog, and the build fails if a macro survives untransformed, which would otherwise render as nothing. Start-up is a promise rather than a top-level await, which made Rolldown split the entry and cost 7.7 KiB. The account menu's two radio groups are named by their labels, so 16-appearance looks for the checked scheme inside its own group. Playwright pins locale en-US. admin first load: 165.4 KiB gzip (was 161.7; budget 170) Co-Authored-By: Claude Opus 5.5 --- biome.json | 1 + lingui.config.ts | 27 ++++ package.json | 4 +- playwright.config.ts | 5 + scripts/e2e-server.mjs | 1 + src/admin/components/account-menu.tsx | 63 +++++++-- src/admin/components/shell.tsx | 63 +++++---- src/admin/i18n.ts | 129 +++++++++++++++++++ src/admin/locales/en.po | 111 ++++++++++++++++ src/admin/locales/zh-CN.po | 111 ++++++++++++++++ src/admin/main.tsx | 34 +++-- src/admin/pages/login.tsx | 22 +++- src/admin/po.d.ts | 10 ++ test/admin/i18n.test.ts | 26 ++++ test/cli/admin-build-reproducibility.test.ts | 1 + test/cli/e2e-isolation.test.ts | 1 + test/e2e/16-appearance.spec.ts | 8 +- test/e2e/20-interface-language.spec.ts | 54 ++++++++ vite.config.ts | 45 ++++++- 19 files changed, 655 insertions(+), 61 deletions(-) create mode 100644 lingui.config.ts create mode 100644 src/admin/i18n.ts create mode 100644 src/admin/locales/en.po create mode 100644 src/admin/locales/zh-CN.po create mode 100644 src/admin/po.d.ts create mode 100644 test/admin/i18n.test.ts create mode 100644 test/e2e/20-interface-language.spec.ts diff --git a/biome.json b/biome.json index 9f58470..2e5487c 100644 --- a/biome.json +++ b/biome.json @@ -203,6 +203,7 @@ "includes": [ "vite.config.ts", "vitest.config.ts", + "lingui.config.ts", "playwright.config.ts", "scripts/e2e-global-setup.mjs", "src/worker/index.ts" diff --git a/lingui.config.ts b/lingui.config.ts new file mode 100644 index 0000000..b9cb9b2 --- /dev/null +++ b/lingui.config.ts @@ -0,0 +1,27 @@ +import { defineConfig } from '@lingui/cli'; +import { formatter } from '@lingui/format-po'; + +/** + * The admin's interface languages (docs/ADMIN_I18N_AND_UI.md §5.1). + * + * English is the source: the sentence in the code is the message, and + * `src/admin/locales/en.po` is what `lingui extract` derives from it. Every + * other language is a translation of that catalog. Adding one is a new entry + * here and in `src/admin/i18n.ts`. + */ +export default defineConfig({ + sourceLocale: 'en', + locales: ['en', 'zh-CN'], + // A message with no translation shows the English, never its id. + fallbackLocales: { default: 'en' }, + // Origins name the file but not the line, so moving code does not rewrite + // every catalog. + format: formatter({ lineNumbers: false }), + catalogs: [ + { + path: '/src/admin/locales/{locale}', + include: ['/src/admin'], + exclude: ['**/node_modules/**', '/src/admin/locales/**'], + }, + ], +}); diff --git a/package.json b/package.json index 0906be6..940342a 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,9 @@ "dev": "pnpm run build:themes && pnpm run build:admin && wrangler dev", "deploy": "pnpm run build && node scripts/ensure-secret.mjs && wrangler deploy", "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p src/core/tsconfig.json --noEmit && tsc -p src/runtime/core/tsconfig.json --noEmit && tsc -p src/runtime/react/tsconfig.json --noEmit && tsc -p src/admin/tsconfig.json --noEmit && tsc -p test/themes/tsconfig.json --noEmit", - "lint": "biome check . && cd template && biome check .", + "lint": "biome check . && pnpm run i18n:check && cd template && biome check .", + "i18n:extract": "lingui extract", + "i18n:check": "lingui check sync && lingui check missing --mode catalog", "lint:fix": "biome check --write . && cd template && biome check --write .", "test": "vitest run --project core --project worker --project worker-setup-key --project worker-unclaimable --project runtime --project runtime-workerd --project runtime-dom --project runtime-build", "test:watch": "vitest", diff --git a/playwright.config.ts b/playwright.config.ts index 9deb872..d84a03b 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -26,6 +26,11 @@ export default defineConfig({ expect: { timeout: 10_000 }, use: { baseURL: 'http://127.0.0.1:8788', + // The specs find controls by their English names. The admin picks its + // interface language from the browser's when nothing is stored, so the + // browser's language is stated here rather than left to the machine's + // (docs/ADMIN_I18N_AND_UI.md §4). + locale: 'en-US', trace: 'retain-on-failure', screenshot: 'only-on-failure', }, diff --git a/scripts/e2e-server.mjs b/scripts/e2e-server.mjs index 28bd4a5..63aabc5 100644 --- a/scripts/e2e-server.mjs +++ b/scripts/e2e-server.mjs @@ -52,6 +52,7 @@ const SNAPSHOT_ENTRIES = [ 'NOTICE', 'site.json', 'vite.config.ts', + 'lingui.config.ts', 'tsconfig.json', 'tsconfig.base.json', 'text-modules.d.ts', diff --git a/src/admin/components/account-menu.tsx b/src/admin/components/account-menu.tsx index 4715994..8340b16 100644 --- a/src/admin/components/account-menu.tsx +++ b/src/admin/components/account-menu.tsx @@ -3,8 +3,11 @@ * (`shell.tsx`). It opens as it arrives, since a click is what asked for it. */ +import type { MessageDescriptor } from '@lingui/core'; +import { msg } from '@lingui/core/macro'; +import { Trans, useLingui } from '@lingui/react/macro'; import { ChevronsUpDown } from 'lucide-react'; -import type { JSX } from 'react'; +import { type JSX, useId } from 'react'; import { useNavigate } from 'react-router'; import { DropdownMenu, @@ -17,6 +20,12 @@ import { DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { SidebarMenuButton } from '@/components/ui/sidebar'; +import { + INTERFACE_LANGUAGES, + type InterfaceLanguage, + setInterfaceLanguage, + useInterfaceLanguage, +} from '../i18n.js'; import { signOut } from '../queries.js'; import { setThemeMode, @@ -25,10 +34,10 @@ import { useThemeMode, } from '../theme-mode.js'; -const SCHEME_LABELS: Readonly> = { - system: 'Same as the system', - light: 'Light', - dark: 'Dark', +const SCHEME_LABELS: Readonly> = { + system: msg`Same as the system`, + light: msg`Light`, + dark: msg`Dark`, }; export function AccountMenu({ @@ -37,37 +46,69 @@ export function AccountMenu({ readonly email: string; }): JSX.Element { const scheme = useThemeMode(); + const language = useInterfaceLanguage(); const navigate = useNavigate(); + const { t, i18n } = useLingui(); + // The menu holds two radio groups; each is named by its label, so neither a + // screen reader nor a test has to guess which one a choice belongs to. + const schemeLabel = useId(); + const languageLabel = useId(); return ( // Not modal: a modal menu marks the rest of the page `aria-hidden` while // it is open, which the accessibility gate rightly flags, and a menu has // no need to trap the page. - - {email === '' ? 'Account' : email} + + {email === '' ? t`Account` : email} navigate('/account')}> - Account and API tokens + Account and API tokens - Colour scheme + + Colour scheme + setThemeMode(value as ThemeMode)} > {THEME_MODES.map((mode) => ( - {SCHEME_LABELS[mode]} + {i18n._(SCHEME_LABELS[mode])} + + ))} + + + {/* Always called this, and each language in its own name; a content + language is never chosen here (docs/ADMIN_I18N_AND_UI.md, D7). */} + + Interface language + + + void setInterfaceLanguage(value as InterfaceLanguage) + } + > + {INTERFACE_LANGUAGES.map((option) => ( + + {option.name} ))} void signOut()}> - Sign out + Sign out diff --git a/src/admin/components/shell.tsx b/src/admin/components/shell.tsx index 0a47283..92c0aee 100644 --- a/src/admin/components/shell.tsx +++ b/src/admin/components/shell.tsx @@ -8,6 +8,9 @@ * because it is true until someone configures the token. */ +import type { MessageDescriptor } from '@lingui/core'; +import { msg } from '@lingui/core/macro'; +import { useLingui } from '@lingui/react/macro'; import { ChevronsUpDown, FileText, @@ -52,7 +55,7 @@ import { useSession, useSettings } from '../queries.js'; import { PurgeNotice } from './saved-note.js'; interface NavItem { - readonly label: string; + readonly label: MessageDescriptor; readonly href: string; readonly icon: typeof FileText; /** Whether the item is the current section for `path`. */ @@ -61,19 +64,19 @@ interface NavItem { const SITE: readonly NavItem[] = [ { - label: 'Content', + label: msg`Content`, href: '/', icon: FileText, active: (path) => path === '/' || path.startsWith('/content'), }, { - label: 'Media', + label: msg`Media`, href: '/media', icon: Image, active: (path) => path === '/media', }, { - label: 'Plugins', + label: msg`Plugins`, href: '/plugins', icon: Plug, active: (path) => path === '/plugins', @@ -82,25 +85,25 @@ const SITE: readonly NavItem[] = [ const SETTINGS: readonly NavItem[] = [ { - label: 'Site', + label: msg`Site`, href: '/settings', icon: Settings2, active: (path) => path === '/settings', }, { - label: 'Appearance', + label: msg`Appearance`, href: '/settings/appearance', icon: Palette, active: (path) => path === '/settings/appearance', }, { - label: 'Email', + label: msg`Email`, href: '/settings/email', icon: Mail, active: (path) => path === '/settings/email', }, { - label: 'Advanced', + label: msg`Advanced`, href: '/settings/advanced', icon: Wrench, active: (path) => path === '/settings/advanced', @@ -141,6 +144,7 @@ function NavGroup({ readonly items: readonly NavItem[]; readonly path: string; }): JSX.Element { + const { i18n } = useLingui(); return ( {label} @@ -148,19 +152,16 @@ function NavGroup({ {items.map((item) => { const active = item.active(path); + const label = i18n._(item.label); return ( - + - {item.label} + {label} @@ -189,15 +190,16 @@ function AccountButton({ readonly busy?: boolean; readonly onOpen?: () => void; }): JSX.Element { + const { t } = useLingui(); return ( - {email === '' ? 'Account' : email} + {email === '' ? t`Account` : email} ); @@ -225,45 +227,49 @@ let toastsWanted = false; /** Where the current page sits: a section, and the page within it. */ function crumbsFor(path: string): readonly { - readonly label: string; + readonly label: MessageDescriptor; readonly href?: string; }[] { if (path === '/' || path === '/content') { - return [{ label: 'Content' }]; + return [{ label: msg`Content` }]; } if (path.startsWith('/content/')) { return [ - { label: 'Content', href: '/' }, - { label: path === '/content/new' ? 'New item' : 'Edit' }, + { label: msg`Content`, href: '/' }, + { label: path === '/content/new' ? msg`New item` : msg`Edit` }, ]; } const setting = SETTINGS.find((item) => item.href === path); if (setting !== undefined) { - return [{ label: 'Settings', href: '/settings' }, { label: setting.label }]; + return [ + { label: msg`Settings`, href: '/settings' }, + { label: setting.label }, + ]; } const area = SITE.find((item) => item.href === path); if (area !== undefined) { return [{ label: area.label }]; } if (path === '/account') { - return [{ label: 'Account' }]; + return [{ label: msg`Account` }]; } - return [{ label: 'Not found' }]; + return [{ label: msg`Not found` }]; } function PageBreadcrumb({ path }: { readonly path: string }): JSX.Element { + const { i18n } = useLingui(); const crumbs = crumbsFor(path); return ( {crumbs.map((crumb, index) => ( - + {index > 0 ? : null} {crumb.href === undefined || index === crumbs.length - 1 ? ( - {crumb.label} + {i18n._(crumb.label)} ) : ( - {crumb.label} + {i18n._(crumb.label)} )} @@ -283,6 +289,7 @@ export function Shell({ // A page reports a failure with `notify`; it is shown as a toast. const message = useNotice(); const siteName = useSettings().name; + const { t } = useLingui(); if (message !== '') { toastsWanted = true; } @@ -311,8 +318,8 @@ export function Shell({ - - + + diff --git a/src/admin/i18n.ts b/src/admin/i18n.ts new file mode 100644 index 0000000..e233c48 --- /dev/null +++ b/src/admin/i18n.ts @@ -0,0 +1,129 @@ +/** + * The interface language (docs/ADMIN_I18N_AND_UI.md, D2 and D7). + * + * The interface language is the language the admin speaks to its operator. + * It is not a content language: the two never default from each other, and + * a site's content languages are whatever codes the site declares. + * + * The choice is kept in this browser, like the colour scheme. Without one, + * the first of the browser's languages the admin has a catalog for is used, + * and English otherwise. It is resolved and its catalog loaded before the + * first render, so the admin never paints in the wrong language. + */ + +import { i18n, type Messages } from '@lingui/core'; +import { useSyncExternalStore } from 'react'; + +/** An interface language the admin has a catalog for. */ +export type InterfaceLanguage = 'en' | 'zh-CN'; + +/** Each interface language, named in itself (D7, rule 2). */ +export const INTERFACE_LANGUAGES: readonly { + readonly tag: InterfaceLanguage; + readonly name: string; +}[] = [ + { tag: 'en', name: 'English' }, + { tag: 'zh-CN', name: '简体中文' }, +]; + +const STORAGE_KEY = 'mallok-admin-language'; + +/** + * Each catalog is its own chunk, fetched when its language is first needed; + * the first load carries no catalog at all. + */ +const CATALOGS: Readonly< + Record Promise<{ readonly messages: Messages }>> +> = { + en: () => import('./locales/en.po'), + 'zh-CN': () => import('./locales/zh-CN.po'), +}; + +function isInterfaceLanguage(value: unknown): value is InterfaceLanguage { + return INTERFACE_LANGUAGES.some((language) => language.tag === value); +} + +/** + * The best interface language for a list of BCP 47 tags, most preferred + * first: an exact match, then a match on the primary language alone + * (`zh-Hans-CN` and `zh` both find `zh-CN`). `undefined` when none matches. + */ +export function matchInterfaceLanguage( + wanted: readonly string[], +): InterfaceLanguage | undefined { + for (const tag of wanted) { + const exact = INTERFACE_LANGUAGES.find( + (language) => language.tag.toLowerCase() === tag.toLowerCase(), + ); + if (exact !== undefined) { + return exact.tag; + } + const primary = tag.split('-')[0]?.toLowerCase(); + const near = INTERFACE_LANGUAGES.find( + (language) => language.tag.split('-')[0]?.toLowerCase() === primary, + ); + if (near !== undefined) { + return near.tag; + } + } + return undefined; +} + +function stored(): InterfaceLanguage | undefined { + try { + const value = window.localStorage.getItem(STORAGE_KEY); + return isInterfaceLanguage(value) ? value : undefined; + } catch { + return undefined; + } +} + +/** The language to start in: the stored choice, the browser's, English. */ +function initialLanguage(): InterfaceLanguage { + return stored() ?? matchInterfaceLanguage(window.navigator.languages) ?? 'en'; +} + +const listeners = new Set<() => void>(); + +async function activate(language: InterfaceLanguage): Promise { + const { messages } = await CATALOGS[language](); + i18n.load(language, messages); + i18n.activate(language); + // What lets a browser choose a Simplified Chinese face for Han characters, + // and what a screen reader pronounces the page in (§5.5). + document.documentElement.lang = language; + for (const listener of listeners) { + listener(); + } +} + +/** Resolves the interface language and loads its catalog; before rendering. */ +export function startInterfaceLanguage(): Promise { + return activate(initialLanguage()); +} + +/** + * Switches the interface language in place and remembers it in this + * browser. Nothing is reloaded, so nothing typed into a form is lost. + */ +export async function setInterfaceLanguage( + language: InterfaceLanguage, +): Promise { + try { + window.localStorage.setItem(STORAGE_KEY, language); + } catch { + // Not remembered; it still applies to this page. + } + await activate(language); +} + +/** The current interface language, re-rendering when it changes. */ +export function useInterfaceLanguage(): InterfaceLanguage { + return useSyncExternalStore( + (listener) => { + listeners.add(listener); + return () => listeners.delete(listener); + }, + () => (isInterfaceLanguage(i18n.locale) ? i18n.locale : 'en'), + ); +} diff --git a/src/admin/locales/en.po b/src/admin/locales/en.po new file mode 100644 index 0000000..03b3e10 --- /dev/null +++ b/src/admin/locales/en.po @@ -0,0 +1,111 @@ +msgid "" +msgstr "" +"POT-Creation-Date: 2026-11-13 04:16-0800\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: @lingui/cli\n" +"Language: en\n" + +#: src/admin/components/account-menu.tsx +#: src/admin/components/shell.tsx +msgid "Account" +msgstr "Account" + +#: src/admin/components/account-menu.tsx +msgid "Account and API tokens" +msgstr "Account and API tokens" + +#: src/admin/components/account-menu.tsx +#: src/admin/components/shell.tsx +msgid "Account menu" +msgstr "Account menu" + +#: src/admin/components/shell.tsx +msgid "Advanced" +msgstr "Advanced" + +#: src/admin/components/shell.tsx +msgid "Appearance" +msgstr "Appearance" + +#: src/admin/components/account-menu.tsx +msgid "Colour scheme" +msgstr "Colour scheme" + +#: src/admin/components/shell.tsx +msgid "Content" +msgstr "Content" + +#: src/admin/components/account-menu.tsx +msgid "Dark" +msgstr "Dark" + +#: src/admin/components/shell.tsx +msgid "Edit" +msgstr "Edit" + +#: src/admin/components/shell.tsx +#: src/admin/pages/login.tsx +msgid "Email" +msgstr "Email" + +#: src/admin/components/account-menu.tsx +msgid "Interface language" +msgstr "Interface language" + +#: src/admin/components/account-menu.tsx +msgid "Light" +msgstr "Light" + +#: src/admin/components/shell.tsx +msgid "Media" +msgstr "Media" + +#: src/admin/components/shell.tsx +msgid "New item" +msgstr "New item" + +#: src/admin/components/shell.tsx +msgid "Not found" +msgstr "Not found" + +#: src/admin/pages/login.tsx +msgid "Password" +msgstr "Password" + +#: src/admin/components/shell.tsx +msgid "Plugins" +msgstr "Plugins" + +#: src/admin/components/account-menu.tsx +msgid "Same as the system" +msgstr "Same as the system" + +#: src/admin/components/shell.tsx +msgid "Settings" +msgstr "Settings" + +#: src/admin/pages/login.tsx +msgid "Sign in" +msgstr "Sign in" + +#: src/admin/components/account-menu.tsx +msgid "Sign out" +msgstr "Sign out" + +#: src/admin/pages/login.tsx +msgid "Sign-in failed." +msgstr "Sign-in failed." + +#: src/admin/pages/login.tsx +msgid "Signing in…" +msgstr "Signing in…" + +#: src/admin/components/shell.tsx +msgid "Site" +msgstr "Site" + +#: src/admin/pages/login.tsx +msgid "The site's admin" +msgstr "The site's admin" diff --git a/src/admin/locales/zh-CN.po b/src/admin/locales/zh-CN.po new file mode 100644 index 0000000..d40fd66 --- /dev/null +++ b/src/admin/locales/zh-CN.po @@ -0,0 +1,111 @@ +msgid "" +msgstr "" +"POT-Creation-Date: 2026-11-13 04:16-0800\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: @lingui/cli\n" +"Language: zh-CN\n" + +#: src/admin/components/account-menu.tsx +#: src/admin/components/shell.tsx +msgid "Account" +msgstr "账号" + +#: src/admin/components/account-menu.tsx +msgid "Account and API tokens" +msgstr "账号与 API 令牌" + +#: src/admin/components/account-menu.tsx +#: src/admin/components/shell.tsx +msgid "Account menu" +msgstr "账号菜单" + +#: src/admin/components/shell.tsx +msgid "Advanced" +msgstr "高级" + +#: src/admin/components/shell.tsx +msgid "Appearance" +msgstr "外观" + +#: src/admin/components/account-menu.tsx +msgid "Colour scheme" +msgstr "配色" + +#: src/admin/components/shell.tsx +msgid "Content" +msgstr "内容" + +#: src/admin/components/account-menu.tsx +msgid "Dark" +msgstr "深色" + +#: src/admin/components/shell.tsx +msgid "Edit" +msgstr "编辑" + +#: src/admin/components/shell.tsx +#: src/admin/pages/login.tsx +msgid "Email" +msgstr "邮箱" + +#: src/admin/components/account-menu.tsx +msgid "Interface language" +msgstr "界面语言" + +#: src/admin/components/account-menu.tsx +msgid "Light" +msgstr "浅色" + +#: src/admin/components/shell.tsx +msgid "Media" +msgstr "媒体" + +#: src/admin/components/shell.tsx +msgid "New item" +msgstr "新建" + +#: src/admin/components/shell.tsx +msgid "Not found" +msgstr "未找到" + +#: src/admin/pages/login.tsx +msgid "Password" +msgstr "密码" + +#: src/admin/components/shell.tsx +msgid "Plugins" +msgstr "插件" + +#: src/admin/components/account-menu.tsx +msgid "Same as the system" +msgstr "跟随系统" + +#: src/admin/components/shell.tsx +msgid "Settings" +msgstr "设置" + +#: src/admin/pages/login.tsx +msgid "Sign in" +msgstr "登录" + +#: src/admin/components/account-menu.tsx +msgid "Sign out" +msgstr "退出登录" + +#: src/admin/pages/login.tsx +msgid "Sign-in failed." +msgstr "登录失败。" + +#: src/admin/pages/login.tsx +msgid "Signing in…" +msgstr "正在登录…" + +#: src/admin/components/shell.tsx +msgid "Site" +msgstr "站点" + +#: src/admin/pages/login.tsx +msgid "The site's admin" +msgstr "站点后台" diff --git a/src/admin/main.tsx b/src/admin/main.tsx index 590506a..a8e024a 100644 --- a/src/admin/main.tsx +++ b/src/admin/main.tsx @@ -1,10 +1,13 @@ /** Admin entry point. */ +import { i18n } from '@lingui/core'; +import { I18nProvider } from '@lingui/react'; import { QueryClientProvider } from '@tanstack/react-query'; import { lazy, Suspense } from 'react'; import { createRoot } from 'react-dom/client'; import { RouterProvider } from 'react-router/dom'; import { APP_BASE, createAdminRouter } from './app.js'; +import { startInterfaceLanguage } from './i18n.js'; import { queryClient } from './queries.js'; import { startThemeMode } from './theme-mode.js'; import './styles.css'; @@ -37,16 +40,25 @@ const inSetup = window.location.pathname.startsWith(`${SETUP_PATH}/`); const root = document.getElementById('app'); -if (root !== null) { +// The interface language and its catalog come first, so nothing is ever +// painted in the wrong language. Not a top-level `await`: Rolldown splits an +// entry that has one into many small chunks, which costs the first load +// several KiB of gzip framing (docs/ADMIN_I18N_AND_UI.md §8). +void startInterfaceLanguage().then(() => { + if (root === null) { + return; + } createRoot(root).render( - - {inSetup ? ( - - - - ) : ( - - )} - , + + + {inSetup ? ( + + + + ) : ( + + )} + + , ); -} +}); diff --git a/src/admin/pages/login.tsx b/src/admin/pages/login.tsx index 7388071..422e0e9 100644 --- a/src/admin/pages/login.tsx +++ b/src/admin/pages/login.tsx @@ -8,6 +8,7 @@ */ import { zodResolver } from '@hookform/resolvers/zod'; +import { Trans, useLingui } from '@lingui/react/macro'; import type { JSX } from 'react'; import { useState } from 'react'; import { useForm } from 'react-hook-form'; @@ -46,6 +47,7 @@ export function LoginPage(): JSX.Element { }); const [error, setError] = useState(''); const siteName = useKnownSettings()?.name; + const { t } = useLingui(); const busy = form.formState.isSubmitting; const { errors } = form.formState; @@ -54,7 +56,9 @@ export function LoginPage(): JSX.Element { try { await signIn(email, password); } catch (caught) { - setError(caught instanceof ApiError ? caught.message : 'Sign-in failed.'); + setError( + caught instanceof ApiError ? caught.message : t`Sign-in failed.`, + ); } }); @@ -63,15 +67,19 @@ export function LoginPage(): JSX.Element { -

Sign in

+

+ Sign in +

- {siteName ?? "The site's admin"} + {siteName ?? t`The site's admin`}
void submit(event)}> - Email + + Email + - Password + + Password + )}
diff --git a/src/admin/po.d.ts b/src/admin/po.d.ts new file mode 100644 index 0000000..fcd865c --- /dev/null +++ b/src/admin/po.d.ts @@ -0,0 +1,10 @@ +/** + * A `.po` catalog, as Lingui's Vite plugin compiles it on import + * (`src/admin/i18n.ts`). + */ +declare module '*.po' { + import type { Messages } from '@lingui/core'; + + /** The compiled messages, keyed by message id. */ + export const messages: Messages; +} diff --git a/test/admin/i18n.test.ts b/test/admin/i18n.test.ts new file mode 100644 index 0000000..8464c2a --- /dev/null +++ b/test/admin/i18n.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, it } from 'vitest'; +import { matchInterfaceLanguage } from '../../src/admin/i18n.js'; + +/** + * With nothing stored, the admin speaks the first of the browser's languages + * it has a catalog for (docs/ADMIN_I18N_AND_UI.md, D2). A Chinese-speaking + * operator must not be shown English because their browser says `zh` or + * `zh-Hans-CN` rather than exactly `zh-CN`. + */ +describe('interface language from the browser', () => { + it.each([ + [['zh-CN'], 'zh-CN'], + [['zh'], 'zh-CN'], + [['zh-Hans-CN', 'en'], 'zh-CN'], + [['ZH-cn'], 'zh-CN'], + [['en-US', 'zh-CN'], 'en'], + [['de-DE', 'zh-CN'], 'zh-CN'], + ])('%j gives %s', (wanted, expected) => { + expect(matchInterfaceLanguage(wanted)).toBe(expected); + }); + + it('gives nothing for languages without a catalog', () => { + expect(matchInterfaceLanguage(['de-DE', 'fr'])).toBeUndefined(); + expect(matchInterfaceLanguage([])).toBeUndefined(); + }); +}); diff --git a/test/cli/admin-build-reproducibility.test.ts b/test/cli/admin-build-reproducibility.test.ts index fdccae2..c914508 100644 --- a/test/cli/admin-build-reproducibility.test.ts +++ b/test/cli/admin-build-reproducibility.test.ts @@ -37,6 +37,7 @@ async function buildCheckout(name: string): Promise { cp('src/admin', join(checkout, 'src/admin'), { recursive: true }), cp('src/core', join(checkout, 'src/core'), { recursive: true }), cp('vite.config.ts', join(checkout, 'vite.config.ts')), + cp('lingui.config.ts', join(checkout, 'lingui.config.ts')), cp('package.json', join(checkout, 'package.json')), cp('tsconfig.json', join(checkout, 'tsconfig.json')), cp('tsconfig.base.json', join(checkout, 'tsconfig.base.json')), diff --git a/test/cli/e2e-isolation.test.ts b/test/cli/e2e-isolation.test.ts index 2f8763b..46aef17 100644 --- a/test/cli/e2e-isolation.test.ts +++ b/test/cli/e2e-isolation.test.ts @@ -461,6 +461,7 @@ describe('the generated browser environment', () => { 'NOTICE', 'site.json', 'vite.config.ts', + 'lingui.config.ts', 'tsconfig.json', 'tsconfig.base.json', 'text-modules.d.ts', diff --git a/test/e2e/16-appearance.spec.ts b/test/e2e/16-appearance.spec.ts index 8d885d6..3e1a411 100644 --- a/test/e2e/16-appearance.spec.ts +++ b/test/e2e/16-appearance.spec.ts @@ -21,9 +21,13 @@ async function choose(page: Page, scheme: string): Promise { /** Opens the account menu and reads which scheme is checked. */ async function chosen(page: Page): Promise { await page.getByRole('button', { name: 'Account menu' }).click(); + // Within its own group: the menu also holds the interface language, whose + // choice is checked too (docs/ADMIN_I18N_AND_UI.md, D7). const name = - (await page.getByRole('menuitemradio', { checked: true }).textContent()) ?? - ''; + (await page + .getByRole('group', { name: 'Colour scheme' }) + .getByRole('menuitemradio', { checked: true }) + .textContent()) ?? ''; await page.keyboard.press('Escape'); await expect(page.getByRole('menu')).toHaveCount(0); return name.trim(); diff --git a/test/e2e/20-interface-language.spec.ts b/test/e2e/20-interface-language.spec.ts new file mode 100644 index 0000000..159baf2 --- /dev/null +++ b/test/e2e/20-interface-language.spec.ts @@ -0,0 +1,54 @@ +import { expect, test } from '@playwright/test'; +import { signIn } from './credentials.js'; + +/** + * The interface language (docs/ADMIN_I18N_AND_UI.md, D2 and D7). + * + * It is chosen in the account menu and kept in this browser only: no cookie, + * nothing the Worker sees. Phase 1 translates the shell and the sign-in page; + * the pages inside the shell still read English. + */ + +test('switches the shell to Simplified Chinese and keeps the choice', async ({ + page, + context, +}) => { + await signIn(page); + const cookiesBefore = await context.cookies(); + await expect(page.locator('html')).toHaveAttribute('lang', 'en'); + + await page.getByRole('button', { name: 'Account menu' }).click(); + // Each language is listed in its own name, under a label that says this is + // the interface's language and not the site's. + await expect(page.getByText('Interface language')).toBeVisible(); + await page.getByRole('menuitemradio', { name: '简体中文' }).click(); + + const sidebar = page.locator('[data-sidebar="sidebar"]').first(); + await expect(sidebar.getByRole('link', { name: '媒体' })).toBeVisible(); + await expect(sidebar.getByText('设置', { exact: true })).toBeVisible(); + await expect(page.locator('html')).toHaveAttribute('lang', 'zh-CN'); + + await page.reload(); + await expect(sidebar.getByRole('link', { name: '媒体' })).toBeVisible(); + await expect(page.locator('html')).toHaveAttribute('lang', 'zh-CN'); + + // The choice lives in this browser's storage, not in a cookie the edge + // cache or the Worker would see. + expect(await context.cookies()).toEqual(cookiesBefore); + + await page.getByRole('button', { name: '账号菜单' }).click(); + await page.getByRole('menuitemradio', { name: 'English' }).click(); + await expect(sidebar.getByRole('link', { name: 'Media' })).toBeVisible(); + await expect(page.locator('html')).toHaveAttribute('lang', 'en'); +}); + +test.describe('a browser that prefers Chinese', () => { + test.use({ locale: 'zh-CN' }); + + test('is greeted in Chinese before anyone has chosen', async ({ page }) => { + await page.goto('/_mallok/app/'); + await expect(page.getByRole('heading', { name: '登录' })).toBeVisible(); + await expect(page.getByLabel('密码', { exact: true })).toBeVisible(); + await expect(page.locator('html')).toHaveAttribute('lang', 'zh-CN'); + }); +}); diff --git a/vite.config.ts b/vite.config.ts index 78f9186..8841aed 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,8 @@ import { fileURLToPath } from 'node:url'; +import { lingui } from '@lingui/vite-plugin'; import tailwindcss from '@tailwindcss/vite'; import react from '@vitejs/plugin-react'; -import { defineConfig } from 'vite'; +import { defineConfig, type Plugin } from 'vite'; /** * The admin single-page app. @@ -12,6 +13,32 @@ import { defineConfig } from 'vite'; * (docs/TECH_STACK.md §6). */ +/** + * Fails the build when a Lingui macro survives to module resolution. + * + * The transform replaces every `@lingui/…/macro` import. If it ever stops + * running — a reordered plugin list, a changed option — the browser build of + * `@lingui/react/macro` is a set of empty functions, so `` would + * render nothing and the build would pass. This turns that silent blank + * into a build error (docs/ADMIN_I18N_AND_UI.md §8). + */ +function refuseUntransformedMacros(): Plugin { + return { + name: 'mallok:refuse-untransformed-lingui-macros', + enforce: 'pre', + resolveId(source, importer) { + if (/^@lingui\/[^/]+\/macro$/.test(source)) { + throw new Error( + `${importer ?? 'A module'} imports ${source}, but Lingui's macro ` + + 'transform did not replace it. Check the lingui() plugin in ' + + 'vite.config.ts.', + ); + } + return null; + }, + }; +} + export default defineConfig(({ command }) => { if (command === 'build') { // Vite computes `isProduction` after loading this file and explicitly @@ -23,7 +50,21 @@ export default defineConfig(({ command }) => { return { root: 'src/admin', base: '/_mallok/app/', - plugins: [react(), tailwindcss()], + // Lingui's macros (``, `t`) compile to catalog lookups here, and + // `.po` catalogs compile on import. Its own transform, not Babel: the + // admin dropped a Babel step once because it could fail silently + // (docs/ADMIN_I18N_AND_UI.md §2.2). + plugins: [ + react(), + lingui({ + macroTransform: true, + configPath: fileURLToPath( + new URL('./lingui.config.ts', import.meta.url), + ), + }), + tailwindcss(), + refuseUntransformedMacros(), + ], resolve: { alias: { // shadcn/ui's own import convention (`@/components/ui/button`). From 5508077caf77d9c213142da572046dc57b582a34 Mon Sep 17 00:00:00 2001 From: JasonYv <233965174+JasonYv@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:24:38 -0800 Subject: [PATCH 03/38] docs: plan the admin's interface languages and interface review Records the owner's decisions D1 to D8 (every recommendation taken), the phases, and phase 0's measurements in this admin's real build. Co-Authored-By: Claude Opus 5.5 --- docs/ADMIN_I18N_AND_UI.md | 584 ++++++++++++++++++++++++++++++++++++++ docs/README.md | 1 + 2 files changed, 585 insertions(+) create mode 100644 docs/ADMIN_I18N_AND_UI.md diff --git a/docs/ADMIN_I18N_AND_UI.md b/docs/ADMIN_I18N_AND_UI.md new file mode 100644 index 0000000..03cce21 --- /dev/null +++ b/docs/ADMIN_I18N_AND_UI.md @@ -0,0 +1,584 @@ +# Admin interface languages and interface review + +- Status: **decided; phases 0 and 1 implemented** on 2026-11-13. The owner + took every recommendation in §3 as written ("按照建议来"): D1 A (Lingui), + D2 B built as A first, D3 C, D4 C, D5 as an addition under plugin API 2, + D6 unchanged, D7 the four rules, D8 C. Phase 0's numbers are in §8; D1 + stands. Phase 2 is next. +- Date: 2026-11-12 +- Asked for by the owner on 2026-11-12, in two parts: the admin and the setup + wizard have no multilingual support, and the admin's interface needs + adjusting. The second part named no page; §2.3 is what looking at every + screen found. + +## 1. Goal + +1. An operator chooses the language the admin and the setup wizard speak. + English and Simplified Chinese ship; a further language is a catalog and + one line in a list, with no change to a page. +2. The interface problems listed in §2.3 are fixed, page by page, without + changing what the admin does. + +Out of scope: any change to the public site or its language packs, the +content model's languages (`site.locales`, `locale`, `translation_group`), +starter content (it is content, not interface), automatic translation of +content, the CLI's messages, right-to-left layout, and any new admin feature. +Three places where `ADMIN.md` describes something the admin does not have +are listed in §9 as conflicts for the owner; this plan does not build them. + +## 2. Where it is today + +Measured in the repository on 2026-11-12, at `a4b10e0`. + +### 2.1 Language + +| Fact | Value | +| --- | --- | +| Translation mechanism | None. Every string is English, written in the JSX | +| Source to cover | 8,765 lines of TypeScript and TSX in `src/admin` outside `components/ui/` (11,184 with it) | +| Document language | `src/admin/index.html` has `lang="en"`, fixed | +| Sentences with markup inside them | 23 uses of `` and 8 of `` or a link inside running text (the wizard's setup-key help, the purge notice, the domain step) | +| Plurals | Seven, each hand-built with `=== 1 ? '' : 's'` or left wrong on purpose ("1 pages", which `01-wizard` asserts) | +| Number and date formatting | Four call sites, three behaviours: `Intl.NumberFormat('en', …)` in `components/record-editor.tsx`; `toLocaleString()` with the browser's locale in `pages/account.tsx` (twice) and `pages/settings-advanced.tsx`; the content list prints `updatedAt.slice(0, 10)` | +| Native dialogs | Two `window.confirm` calls with long English sentences (`pages/settings-site.tsx`) | +| First load | **161.7 KiB gzip of 170** (`node scripts/admin-size.mjs` on the existing build output): 8.3 KiB of headroom | +| Strings from themes | `theme.json`: `kinds.*.label`, each field's `label`, `help` and `group`, each option's `label`; `select` `choices` are bare strings that are both the stored value and the text shown. English only | +| Strings from plugins | `plugin.json`: `name`, `description`, each setting's and secret's `label`, each panel's `label`, column labels, action labels, a script's `purpose`; badge cells print the row's raw value. English only | +| Strings from the Worker | 146 `problem(status, message)` calls in `src/worker` and `src/plugins`; the body is `{ "error": "" }`, sometimes with `errors: { field: "" }`. **There are no error codes.** Many messages are assembled with values in them | +| Email | The inquiry notification to the operator is English only; the autoreply to a visitor has English and Chinese chosen by the *content* language of the page (`src/plugins/inquiry/emails.ts`) | +| Browser tests | 41 tests in 20 spec files; 176 selectors by role, 62 by label, 20 by text — all English | +| Where a preference could live | Nowhere yet. `admin_user` has `id`, `email`, `password_hash`, `password_params`, `created_at` (`DATA_MODEL.md §2.8`); the colour scheme and the sidebar's state are in `localStorage` | + +Two things already in the repository look reusable and are not, as they are: + +- **A theme's `locales/.json`** is the public site's text + (`THEME_FORMAT.md §10`): a flat map read by templates, keyed by the + *content* language (`zh`), with no interpolation. A few keys coincide with + field names (`moq`, `lead_time`, `grade` in Atelier's pack) but they are + what a visitor reads, not what an operator reads, and no option label + ("Hero headline") is there. See D4. +- **The content editor's language bar** switches which translation is being + edited. It is the control most likely to be mistaken for an interface + language switch. See D7. + +### 2.2 What the libraries cost, measured + +**Method.** A throwaway Vite 8.3.8 project (React 19.2.8, +`@vitejs/plugin-react` 6.3.0), outside the repository. One small screen was +written once per approach: a heading, a sentence with a value in it, a +plural, two buttons, and a switch that loads the other language's catalog +with a dynamic `import()`. The number is gzip of what `index.html` +references, as `pnpm admin:size` counts it; catalogs are separate chunks in +every variant and are not in it. **These are a scaffold's numbers**: good +for what a library adds, not for this admin's total, which phase 0 measures. + +| Approach | Versions | Adds to first load | +| --- | --- | ---: | +| React only | — | 58.0 KiB (base) | +| In-repository: a context, `{name}` substitution, plural forms picked with `Intl.PluralRules` | — | **+0.9** | +| The same with a splitter for `…` inside a message | — | **+1.0** | +| Lingui, runtime only, catalogs compiled by hand | `@lingui/core`, `@lingui/react` 6.12.0 | **+3.3** | +| Lingui as it is meant to be used: `Trans`, `Plural` and `t` macros, `lingui extract`, `.po` catalogs compiled by its Vite plugin | + `@lingui/vite-plugin`, `@lingui/cli` 6.12.0 | **+4.2** | +| An in-repository context around `intl-messageformat` | 12.1.5 | +10.3 | +| FormatJS | `react-intl` 12.1.7 | +14.6 | +| i18next, its own plural format | `i18next` 27.1.1, `react-i18next` 18.0.1 | +17.6 | +| i18next with ICU messages | + `i18next-icu` 2.7.0 | +29.8 | + +Also established by running it, not from memory: + +- **Lingui's macro build works on this stack without Babel or SWC.** + `lingui({ macroTransform: true })` beside `@vitejs/plugin-react` built + under Vite 8; its installation page (read 2026-11-12) says this path + "doesn't need `@lingui/babel-plugin-lingui-macro` or `@lingui/swc-plugin`". + That matters here: phase 5 of the last migration deleted the admin's Babel + transform because it could fail silently (`ADMIN_MIGRATION.md §8`). +- **Extraction works.** `lingui extract` found all six messages of the + screen, wrote `en.po` and `zh-CN.po`, and reported "zh-CN: 6 total, 6 + missing". A sentence with markup became one message with numbered + placeholders (`Printed once by <0>mallok create. …`), so a translator + can reorder it. +- **The built page ran in Chromium in both languages**, with the right + plural form, `` following the choice, and the second catalog + fetched only on the switch. The compiled Chinese catalog for the six + messages was 0.3 KiB. +- **Playwright's default context reports `navigator.language` as `en-US`** + on this (Chinese-language) machine, so a test that does not ask for a + locale gets English from browser detection. + +Read from current documentation on 2026-11-12, not measured: + +| | ICU plurals and select | Keys checked by the compiler | Extraction from source | +| --- | --- | --- | --- | +| In-repository | No. Plural forms only, by category | Yes, if catalogs are TypeScript objects of one type | None; keys are written by hand | +| Lingui | Yes ("ICU MessageFormat under the hood") | There are no keys to mistype with macros: the English sentence in the source is the message. Its docs also list a "Typed Message IDs" guide, not read here | `lingui extract`; `compile` produces the runtime catalogs and "ships no message parser" | +| FormatJS | Yes | Not established here | `formatjs extract` | +| i18next | Its own `_one` / `_other` suffixes on `Intl.PluralRules`; ICU through `i18next-icu` | Yes, by augmenting `CustomTypeOptions`; its docs warn of slower type checks and lost inference for template-literal keys | Separate tools; not examined | + +Lingui's installation page asks for Node 22.19 or higher; `.nvmrc` is +22.22.2. + +### 2.3 The interface, from screenshots + +A separate local instance (its own port and state directory, the +`trade-b2b` starter, the Atelier theme, three content languages) was driven +with Playwright through the wizard and every admin page at 1440 px and +390 px, light and dark: 86 screenshots, kept outside the repository. The +content list, the Site page, the plugins page and the editor were then +re-captured with their text replaced in the page by Chinese and by German +of realistic length. What follows is from those images; where a claim is +from code it says so. + +**What holds up.** Light and dark are consistent on every page. No page +scrolls sideways at 390 px. With Chinese or German text nothing overflowed +or was clipped in the sidebar (256 px wide; "Erweiterte Einstellungen" +fits), the buttons, the badges or the table headings. Chinese renders in the +system's CJK face through the existing stack at the existing sizes and line +heights (14 px on 20 px in controls and tables) and reads well — **on macOS, +the only system measured.** + +| # | Where | What is wrong | What it should become | +| --- | --- | --- | --- | +| U1 | Every page | The standing "Changes reach visitors within 1 minute" notice is three lines at 1440 px and **seven at 390 px, above every page, the editor included**. It names `CF_API_TOKEN`, `CF_ZONE_ID` and "Worker secrets" — the vocabulary `ADMIN.md §2` keeps to Advanced | One line: the sentence in its title and a "Why?" link to Advanced → Diagnostics, where the secret names already are. Still standing, still `role="note"` | +| U2 | Every page | Three widths on one screen: the notice spans the window; the content list and editor are 68 rem; settings pages are 56 rem **left-aligned inside the centred 68 rem column**, so at 1440 px they sit 84 px from the sidebar and 205 px from the right edge | One column rule: the notice, the page header and the page share a left edge and a width; forms cap their own fields, not the page | +| U3 | Sidebar | **Inquiries, the thing a trade site's operator opens every day, is the last block of the Plugins page**, about 1,500 px down, under nine settings and a secret. The last migration's D4 recommended "each plugin's panels listed under Plugins"; the sidebar that shipped has one Plugins link. There is also no way to open the public site from the admin | See D8 | +| U4 | Content list | The Type column prints the kind's id (`article`) while the Type filter, one row above, prints the theme's label ("Note"); statuses are raw lowercase values; languages are bare codes (`en`); the date is a sliced ISO string | Labels from the theme, status names from the catalog, language names from `Intl.DisplayNames` with the code beside them, dates through one formatter (§5.4) | +| U5 | Content list | A "Media" button duplicates the sidebar item beside it. "New" does not say what it makes. Previous and Next are drawn, disabled, when there is one page. "Nothing here yet." is shown both for an empty site and for a filter that matches nothing, with no action in either | Drop "Media". Hide the pager when there is nothing to page. Two empty states: an empty site offers "Create the first page"; an empty filter says so and offers "Clear filters" | +| U6 | Content list, 390 px | The table scrolls sideways and Path and Updated are off screen, so a phone shows title, type and status only — by accident, not by design | Below `md`, a row is the title with type and status under it; Path and Updated are dropped on purpose | +| U7 | Editor, 1440 px | The editor is held to 68 rem, so each pane is about 330 px while 350 px of the window is empty. Markdown wraps at about 35 characters and the preview shows the theme's phone layout. `ADMIN.md §10` says the editor "fills the window"; `§6.1` says the columns collapse, and the code has no collapse control | The editor route is full-bleed. The field pane collapses to a rail; the source and preview split what is left | +| U8 | Editor | Nothing says whether the open item is published, a draft or scheduled, or when it was last saved, and there is no link to it on the site. `ADMIN.md §6.1` draws a status bar with exactly those | A status badge and "Updated …" beside the title controls, and "View on site" for a published item | +| U9 | Editor, 390 px | Fields, then the whole source, then the preview, in one column about 2,000 px tall; Save draft and Publish scroll away with the top | Three tabs — Fields, Write, Preview — and the two buttons in a bar that stays on screen | +| U10 | Four places | The language of *content* is chosen with four different controls: a select in the list's filters, chips ("en", "Create zh") in the editor, an "Editing" select on Appearance, and a suffix on a label ("Tagline (zh)") on Site. All show bare codes | One component, always labelled "Content language", always showing the language's name and code. This is also what keeps it apart from the interface language (D7) | +| U11 | Plugins | The card opens with Hooks, Client JavaScript and a script URL; the settings follow; the panel is last. Help is written into labels ("From address for inquiry email (empty uses the sender in Settings → Email)") although fields have a `help` key. A Liquid body is typed into a one-line input. The Status filter is a free-text box with the placeholder "any". "Mark replied" and "Mark spam" are enabled with no row selected (from code: only the pager is ever disabled) | Order: panel link, settings, secrets, then "Technical details" (hooks, scripts, cache effect) closed by default — still there, as `ADMIN.md §10` requires. The inquiry manifest moves its parentheses into `help` and its body to `text`. A filter on a column with known values is a select. Bulk actions are disabled until a row is selected | +| U12 | Settings → Site | "Only this host is indexable. Without one, every page is served noindex and the edge cache does not apply." and "An R2 custom domain … through the Worker." are infrastructure wording on the first settings page. One textarea per extra language is stacked full-width (two here; six languages would be six). The first card has a Save button; the Languages card below acts at once — two models on one page with nothing telling them apart. A new language is typed as a code | Plain wording, with the detail under Advanced. Taglines for other languages behind the one content-language control (U10). Cards that act at once say "Applies immediately" where a Save button would be. Adding a language offers names, with a typed code still accepted | +| U13 | Settings → Appearance | 370 px of facts and a deploy notice stand between the heading and the first option an operator can change | Options first; the theme's facts and the deploy note after them | +| U14 | Settings → Advanced | The one action an operator needs here, "Export everything", is the fourth card. Storage rows are raw keys (`jobsPending`, `fragments`). On a fresh site five of five diagnostics are orange | Backup first. Labels for the storage rows. Orange only for what stops something working; "not set up yet" is neutral | +| U15 | Saving, everywhere | Success is an inline badge beside the button, failure is a toast, sign-in failure is an inline box. With no purge token, a *successful* save is the orange warning badge "Saved — visitors see it within 1 minute", which reads as a problem | Success is always the green badge "Saved"; the delay is plain text after it. Failures stay where they are | +| U16 | Wizard, step 2 | The first question a non-technical owner meets is "Main language" as a free-text code and "Other languages" as "zh, de", comma separated | A select of language names for the main language and a multi-select for the others, drawn from the active theme's packs first, with a typed code still accepted | +| U17 | Wizard | Five numbered dots for what `ADMIN.md §5` calls four steps: "Finish" is a result, not a step. There is no Back. The password is typed once, unseen, with no way to show it. Step 4 is two paragraphs of Cloudflare dashboard directions plus the secret names | Four steps and a result screen. Back on steps 2–4. A show-password toggle. Step 4 keeps its first, honest paragraph; the directions become a link to the documentation | +| U18 | Sign-in | "The site's admin" names no site, and there is nowhere to choose a language before signing in | The site's name where the session-less API can give it, otherwise as now; the interface-language control of D2 | +| U19 | Empty states | "Nothing here yet.", "No media yet." and "No rows yet." are three wordings in two dashed boxes that look like the upload drop zone next to them | One empty-state block: what is empty, and the one action that fills it | +| U20 | Type size in Chinese | Sidebar group labels and badges are 12 px. Latin survives that; Chinese at 12 px is at the edge of comfortable | Under a CJK interface language these two go to 13 px. No other size changes | + +## 3. Decisions the owner has to make + +### D1 — The translation mechanism + +| | A. Lingui | B. In the repository | C. FormatJS or i18next | +| --- | --- | --- | --- | +| First load (§2.2) | +4.2 KiB | +1.0 KiB | +14.6 to +29.8 KiB | +| Fits 170 KiB | Yes, with about 4 KiB left | Yes, with about 7 KiB left | **No.** The budget would have to be raised again, nine days after it was raised to 170 | +| What a page looks like | The English sentence stays in the JSX, wrapped: `Save draft` | Every sentence moves to a catalog and the JSX holds a key: `t('editor.saveDraft')` | Keys, as B | +| Plurals, sentences with markup | ICU; markup as numbered placeholders | Plural categories only; a hand-written splitter for markup | Yes | +| Missing translation | Reported by the extractor | A type error | Varies | +| Cost | Four packages; a build-time transform in `vite.config.ts` again; `.po` files | A formatter and a splitter written and owned here; ~8,700 lines re-keyed by hand | Size | + +**Recommended: A, Lingui, confirmed by phase 0 in this admin's own build.** +It fits, it was seen to work on this stack without Babel, and it leaves the +English in the source — so the browser tests' selectors and the code they +drive stay readable side by side. B is smaller, but it is writing the +library: `TECH_STACK.md §11` rule 6 says adding no dependency is not a +reason to hand-write what a mature ecosystem has solved, and that rule +names parsing. If phase 0 finds Lingui does not fit or its transform is +fragile here, B is the fallback and C is not. + +### D2 — Where the operator's choice lives + +| | A. This browser only | B. The account, mirrored in the browser | C. A site-wide default | +| --- | --- | --- | --- | +| Storage | `localStorage`, like the colour scheme | A nullable `admin_user.ui_locale` column (migration `0010`, additive), plus `localStorage` | A `site` column | +| Before sign-in (wizard, sign-in page) | Works | Works, from the mirror or the browser's language | Needs an unauthenticated read | +| A second browser or a phone | Asks again | Follows the operator | Follows the site, not the person | +| Gives the Worker a language for operator email | No | Yes | Yes | + +**Recommended: B, built as A first.** Phase 1 ships A: the choice in +`localStorage`, else the first of `navigator.languages` the admin has a +catalog for, else English. Phase 3 adds the column and one field on the +existing account endpoint; from then the account's value wins after sign-in +and is copied to the browser, so the next sign-in page is already in it. The +wizard's choice is carried into the account when it creates the +administrator. C is not recommended: 0.1 has one administrator, and a site +default would be a third place to look for no one's benefit. + +### D3 — The Worker's messages + +| | A. Codes, translated in the admin | B. `Accept-Language`, translated in the Worker | C. Codes where they exist, the Worker's English otherwise | +| --- | --- | --- | --- | +| API change | `code` and `params` added beside `error`; `errorCodes` beside `errors` | None in shape; the same request now answers in different languages | As A, additive | +| Catalogs | In the admin, on demand | In the Worker script, every language, on the render path's size budget | In the admin | +| The CLI and scripts | Unaffected: `error` stays English | Must send English or parse translated text | Unaffected | +| Work | All 146 sites before anything is translated | All 146 sites and a formatter in the Worker | Incremental | + +**Recommended: C.** `error` stays exactly as it is — the CLI prints it, and +it is the fallback. A site that gains a `code` also gains its `params`, and +the admin shows its own sentence when its catalog has that code and the +Worker's English when it does not. English is then the worst case, never a +blank or a key. Order of work: sign-in and setup, content save, media +upload, settings, then the rest. A plugin's own validation messages follow +D5. + +### D4 — Labels declared by themes + +Kinds, fields, groups, help text and options are English in `theme.json`. + +| | A. Leave them English | B. Reuse `locales/.json` | C. A separate, optional admin catalog per theme | +| --- | --- | --- | --- | +| Contract change | None | The public pack gains admin keys | `admin/.json` beside `theme.json`: a flat map keyed by declaration path (`kinds.product.label`, `kinds.product.fields.grade.label`, `options.hero_title.label`, `groups.Specification`) | +| Result | A Chinese interface with English field labels in the editor — the page an operator uses most | Visitor text and operator text in one file, keyed by content language (`zh`), not interface language (`zh-CN`) | Themes without the file work as today | + +**Recommended: C.** The file is optional, additive, validated at build time +like the public packs, and bundled the same way. The Worker overlays it on +the manifest it already serves from `GET /_mallok/api/theme`, choosing by +the `Accept-Language` the admin sends (§5.3) — the admin's code does not +change and no theme string enters the admin bundle. A missing key falls back +to the declared English. `THEME_FORMAT.md §10` gains a section; the five +official themes get `zh-CN`. **Not solved here:** a `select`'s `choices` are +stored values; showing a translated choice needs a value/label form of +`choices`, which is a change to the field schema and is left as an open +question (§9). + +### D5 — Labels declared by plugins + +The same shape as D4, for `plugin.json`: `admin/.json` in the +plugin's directory, keyed `name`, `description`, `settings..label`, +`settings..help`, `secrets..label`, `panels..label`, +`panels..columns.`, `actions.`, `values..` for +badge cells (`new`, `replied`, `spam`), and `errors.` for a plugin +that returns codes under D3. + +**Recommended: take it, as an addition under plugin API 2** +(`PLUGIN_API.md §13.1`: version 2 only adds). A plugin without the file is +shown in English, so the official `inquiry` plugin keeps running unedited as +the compatibility proof and gets its `zh-CN` file as a separate commit. A +site-level plugin such as Nundar's gets translated panels by adding one +file. + +### D6 — Email and what the wizard writes + +- **Starter content** stays as it is: it is content, in the content's + languages. +- **The visitor's autoreply** already follows the content language of the + page. Not touched. +- **The operator's inquiry notification** is the one message addressed to + the admin's reader. **Recommended: leave it English in this plan**, and + decide after D2's column exists whether it should follow the + administrator's `ui_locale`. It is sent from a visitor's request, where no + session says who will read it, and the recipient is an address in the + plugin's settings, not an account. + +### D7 — Keeping the interface language apart from content languages + +**Recommended, as rules:** + +1. The interface language is chosen in exactly three places: the account + menu (a radio group under "Colour scheme"), the sign-in page and the + wizard (a small menu in the corner). Never in a page's toolbar. +2. It is always called "Interface language" and lists each language in its + own name: "English", "简体中文". +3. A content language is always called "Content language" (or "Site + languages" in Settings), always through the one component of U10, and + always shows name and code: "German (de)". +4. In data they do not meet: interface languages are BCP 47 tags the admin + has catalogs for (`en`, `zh-CN`); content languages are whatever codes + the site declares. Neither defaults from the other, in either direction — + a Chinese-speaking operator of an English-only site is the common case. + +### D8 — How much of §2.3 to do, and the sidebar + +| | A. Translation only | B. Translation and the review's fixes | C. B, and plugin panels in the sidebar | +| --- | --- | --- | --- | +| Covers | Phases 0–3 | Phases 0–4: U1, U2, U4–U20 | B plus U3 | +| Changes behaviour | No | Layout and wording, no flow | A new route per declared panel | + +**Recommended: C.** U3 is the finding that matters most to a trade site: a +declared panel appears under Site in the sidebar by its label +("Inquiries"), at `/plugins//`, and the Plugins page keeps +the switch, settings and secrets with a link to the panel. A panel attached +to a content kind stays in that kind's editor and is not listed. A link to +the public site joins the sidebar's header. The order of the fixes inside +phase 4 is the owner's taste as much as anyone's; the proposed order is +there. + +## 4. Constraints that do not move + +| Constraint | Source | What it means here | +| --- | --- | --- | +| First load ≤ 170 KiB gzip | `ADMIN.md §13`, `pnpm admin:size` | 8.3 KiB of headroom. English is the fallback and is compiled into the entry only if phase 0 shows that costs less than a second request; every other catalog is a chunk fetched on demand. Each phase reports the number | +| Everything in the repository is English | `CONVENTIONS.md`, Style | Source strings, comments and tests stay English. A catalog in another language is a translation "where it serves a real user", the same footing as a theme's `zh.json` | +| No serious or critical axe violation, light and dark | `test/e2e/05-accessibility.spec.ts` | Run in both interface languages. `` follows the choice; an untranslated English fragment inside a Chinese page is acceptable to axe but is a catalog defect | +| The browser tests find controls by English role, label and text | `test/e2e` | English is what a context with no stored choice and an English browser gets. `playwright.config.ts` pins `locale: 'en-US'` rather than rely on the default seen in §2.2 | +| The Worker validates; the browser shows what comes back | `tasks/TASK-28.md` | D3 changes how an error is worded on screen, never who decides it | +| Errors carry no SQL, bucket names, ids or stack traces | `SECURITY.md` | `params` under D3 are the values already in today's message, nothing more | +| Migrations are additive and forward-compatible | `DATA_MODEL.md` | `ui_locale` is a nullable column; an older Worker ignores it | +| Themes and plugins ship no admin code | `ADMIN.md §7` | D4 and D5 add data files, not code | +| Version 1 plugins run unchanged | `PLUGIN_API.md §13.1` | D5 is optional and additive | +| Infrastructure words only under Advanced | `ADMIN.md §2` | Applies to the translations as much as to the English; U1 and U12 remove existing breaches | +| New dependencies are registered | `TECH_STACK.md §11` | Exact versions, licence, layer and measured size, in a dependency-only commit; released at least two weeks earlier, as the last migration held itself to | +| No release is implied | — | When to publish is the owner's call | + +## 5. Design + +### 5.1 Catalogs and loading + +`src/admin/locales/.po`, one per interface language, with `en` the +source. A list of supported tags and their own names lives in one module; +adding a language is a new `.po` and one entry. The provider sits above both +the router and the wizard in `main.tsx`, resolves the language before the +first render (D2's order), sets `document.documentElement.lang`, and loads +that language's chunk. Switching loads the other chunk and re-renders in +place: no reload, and nothing typed into a form is lost. + +Messages follow three rules. A sentence is one message, markup included, +never fragments joined in code. A count goes through a plural, including in +English ("1 page"). Nothing an operator reads is assembled from a server +value and a client word. + +### 5.2 What is not translated + +Values that are data: content titles, slugs, paths, language codes, plugin +and theme ids, token scopes, secret names. Words that are names: Mallok, +Markdown, Resend, Turnstile, Cloudflare. + +### 5.3 What the admin tells the Worker + +`src/admin/api.ts` is the one place requests are made; it sends the +interface language as `Accept-Language`. The Worker uses it for one thing +only: choosing the admin catalog of a theme or plugin to overlay on the +declarations it returns (D4, D5). Error text does not vary by it (D3). No +response under `/_mallok/` is cached, so the header creates no cache +variance. + +### 5.4 Formatting + +One module wraps `Intl.DateTimeFormat`, `Intl.NumberFormat`, +`Intl.RelativeTimeFormat` and `Intl.DisplayNames`, always called with the +interface language. The four call sites of §2.1 move to it, and +`saved-note.tsx`'s hand-built "1 minute" becomes a plural. Money in a +record keeps its declared currency and takes the interface language's +grouping. + +### 5.5 Typography + +The system stack stays; no font file is added. `lang="zh-CN"` on the +document is what lets a browser pick a Simplified Chinese face for Han +characters, so it is set before the first paint. U20 is the one size +change. **Windows and Linux were not measured**; phase 2's gate includes a +screenshot on each. + +## 6. Phases + +Sizes are relative — S under a day, M a few days, L a week or more — and +are estimates. + +### Phase 0 — Spike and numbers (S) + +Throwaway branch; only §8 of this file merges. + +1. Add the D1 choice to this admin's real build, wrap the shell and the + sign-in page, and record `pnpm admin:size`, with English in the entry + and with English as a chunk. +2. Confirm the build fails loudly, not silently, when the transform is + missing or a catalog does not compile. +3. Find how a missing translation fails the gate (the extractor reported + counts in §2.2; whether a flag turns that into an exit code was not + checked). +4. Count the messages: extract the whole admin once and record the total. + +**Gate:** the measured first load in §8, and D1 confirmed or switched to B. + +### Phase 1 — Foundation (S) + +The provider, the language list, the formatter module, the interface +language control in the account menu, the sign-in page and the wizard +(D7), ``, the choice in `localStorage` (D2, option A). +`playwright.config.ts` pins `en-US`. The shell and the sign-in page are +translated; every other page still reads English. + +**Gate:** all browser tests pass unchanged; a new spec switches to 简体中文 +from the account menu, sees the sidebar and `` change, reloads +and finds the choice kept, and finds no cookie set. + +### Phase 2 — Every string in the admin (L) + +One page per commit, in the last migration's order (settings, account, +content list, media, plugins and panels, record editor, content editor, +wizard), then the form generator's own messages ("This field is +required."). Each commit wraps the page's strings and adds its `zh-CN`. +The two `window.confirm` sentences move into the catalog. English wording +is not edited here, with one exception: "1 pages" becomes "1 page", and +`01-wizard`'s assertion changes with it and says why. + +**Gate:** the extractor reports nothing missing for `zh-CN`; a +pseudo-language run (every message replaced by a marked string) shows no +unmarked sentence on any page or overlay; axe is clean in both languages; +screenshots of every page in Chinese at both widths, on macOS, Windows and +Linux, reviewed by the owner — who is also the reviewer of the Chinese +wording. + +### Phase 3 — Strings from outside the bundle (M) + +- D2's column and the account endpoint's field; the wizard passes its + choice when it creates the administrator. +- D3: `code` and `params` on the Worker's errors, in the order given there; + the admin's catalog gains each code as it lands. +- D4 and D5: the admin catalog files, their build-time validation, the + overlay in the two endpoints, `zh-CN` for the five official themes and + the `inquiry` plugin. `THEME_FORMAT.md`, `PLUGIN_API.md` and + `DATA_MODEL.md` are revised in the same commits as the code. + +**Gate:** worker tests for the overlay (present, absent, a missing key) and +for an error's `code`; the Chinese spec opens the editor of a product and a +plugin panel and finds declared labels in Chinese; a deliberately failed +sign-in and a refused save are read in Chinese; the Worker's bundle size is +reported. + +### Phase 4 — The review's fixes (M–L), per D8 + +One finding or one page per commit, proposed order: U1 and U2 (every page +improves at once), U15, U10, U4–U6, U7–U9, U16–U18, U11–U14, U19, U20, +then U3 if D8 is C. A fix that changes English wording changes the catalog +and its translation in the same commit. + +**Gate:** per commit, the page's browser tests pass — a selector that has to +change says why in its diff — axe is clean in both languages, and a +before-and-after screenshot goes to the owner. + +### Phase 5 — Close (S) + +`ADMIN.md` gains a section on the interface language and is corrected where +phase 4 changed a page; `TECH_STACK.md §6` and `§11.1`; `THIRD_PARTY_NOTICES` +regenerated; the CHANGELOG; a short "adding an interface language" note. + +## 7. Verification + +- **The gate, every phase:** `pnpm lint && pnpm typecheck && pnpm test && + pnpm build && pnpm bundle:size && pnpm admin:size`, and `pnpm test:e2e`. +- **Behaviour:** the existing browser tests, in English, unchanged except + where §6 names a change. +- **The other language:** one ordered spec in 简体中文 covering the switch, + its persistence, a declared label, a translated error, and the wizard — + which, because the wizard runs once per database, is driven in Chinese in + a context of its own inside `01-wizard`'s run, or against a mocked setup + API as the last migration did for its screenshots. Phase 1 decides which. +- **Accessibility:** `05-accessibility` runs its page list once per + interface language. +- **Completeness:** the extractor's missing count and the pseudo-language + run of phase 2. +- **Size:** `pnpm admin:size` in every commit message of phases 1–4. +- **Looks:** screenshots for the owner; no visual-regression tooling is + added. + +## 8. Measurements + +Measured 2026-11-13 in this admin's real build (Vite 8.2.2, Rolldown), with +Lingui 6.11.0 — 6.12.0, which §2.2 measured, was ten days old, and §4 holds +new dependencies to two weeks. The shell, the account menu and the sign-in +page were wrapped: 25 messages. + +| Build | First load (gzip) | Change | +| --- | ---: | ---: | +| Before, `main` at `a4b10e0` | 161.7 KiB | — | +| Lingui, catalogs as chunks, `await` at the top of `main.tsx` | 173.1 KiB | **+11.4, over budget** | +| Lingui, catalogs as chunks, start-up as a promise | **165.4 KiB** | **+3.7** | +| The same with English compiled into the entry | 165.7 KiB | +4.0 | + +- **A top-level `await` in the entry costs 7.7 KiB.** Rolldown split the + entry into 22 small preloaded chunks instead of 6, and each pays its own + gzip framing. `main.tsx` starts the language with a promise and renders + in its `then`; the comment there says why. +- **English stays a chunk.** Compiled into the entry it cost 0.3 KiB for 25 + messages and grows with every one; as a chunk it is one small request + that starts before React renders. +- **The scaffold's +4.2 KiB was close**: the real figure is 3.7 KiB, leaving + 4.6 KiB of the 170. +- **A missing transform fails the build, loudly — but only because of a + guard.** Without the transform the `.po` imports fail to parse, which is + loud. With the transform switched off and the catalogs still compiling + (`macroTransform: false`), the build passed: `@lingui/react/macro`'s + browser build is empty functions, so `` renders nothing. A + `resolveId` guard in `vite.config.ts` now fails the build naming each + module that still imports a macro; tried with the option switched off. +- **A broken catalog fails the build** with a parse error naming the file. +- **A missing translation fails `pnpm lint`.** `lingui check missing` passes + by default even with a missing translation, because English fills it in; + `--mode catalog` is the one that fails (exit 1, "Found 1 missing + translation(s) before applying fallbackLocales"). `lingui check sync` + fails (exit 1) when a sentence in the source has changed and the catalogs + were not re-extracted. Both run in `pnpm lint` as `pnpm i18n:check`. +- **Extraction is reproducible**: catalogs carry origins without line + numbers, and a second `lingui extract` a minute later wrote identical + bytes. The admin build stayed reproducible across checkout paths + (`test/cli/admin-build-reproducibility.test.ts`, which now copies + `lingui.config.ts` too). +- **Not counted: the whole admin's messages.** The extractor counts only + wrapped messages, so step 4's total is known only once phase 2 has wrapped + them; it will be recorded there. +- **The rest of the gate:** `pnpm lint`, `typecheck`, `test` (1460 tests), + `build`, `bundle:size` (Worker 310.3 KiB gzip) and `admin:size` passed; + `pnpm test:e2e` passed, 47 specs, including the new + `20-interface-language.spec.ts`. One `pnpm test` run in three had one + failing test that two reruns did not repeat; it was not identified. + +Phase 1 as built: + +- `src/admin/i18n.ts`: the two languages and their own names, the choice in + `localStorage` (`mallok-admin-language`), else the browser's languages + matched exactly and then by primary subtag (`zh`, `zh-Hans-CN` → `zh-CN`), + else English; `` follows. `zh-TW` also matches `zh-CN` by that + rule — better than English for a reader of Traditional Chinese, and a + Traditional catalog would take it over. +- The account menu gains "Interface language" under "Colour scheme"; each + radio group is now named by its label, which `16-appearance` relied on + not needing — its selector changed and says why. +- `playwright.config.ts` pins `locale: 'en-US'`. +- Not yet done from phase 1's list: the language control on the sign-in + page and in the wizard (the sign-in page already follows the browser), and + the formatter module of §5.4. Both land at the start of phase 2. + +## 9. Risks and open questions + +| Risk | Why it is real | What contains it | +| --- | --- | --- | +| The first load passes 170 KiB | 8.3 KiB of headroom; the scaffold says 4.2, and a scaffold undercounts shared code as often as it overcounts | Phase 0 measures in the real build before anything merges | +| A build-time transform fails silently | It happened to this admin once, with signals | Phase 0, step 2; a build check that the entry contains no untransformed macro | +| Half-translated screens | 8,700 lines are wrapped by hand over many commits | English is always the fallback; the pseudo-language gate; one page per commit | +| Tests rewritten to fit | A wrapped string can change by a space or a quote | Phase 2 edits no English, and the unchanged suite is the judge | +| Translations rot | A new English sentence has no Chinese until someone writes it | The extractor's missing count is in the gate | +| The Chinese is correct and reads badly | Interface Chinese has conventions a literal translation misses | The owner reviews phase 2's screenshots; a short glossary (发布, 草稿, 询盘, 内容语言, 界面语言) is agreed before phase 2 starts | +| Theme and plugin authors do not ship catalogs | The file is optional | The declared English shows; nothing breaks | + +Conflicts between documents and code, found on the way and **not resolved +by this plan**: + +1. `ADMIN.md §4` lists search on the content list and a Navigation editor + under Settings; the admin has neither, and Advanced tells the operator + navigation is among the things that change instantly. +2. `ADMIN.md §6.1` draws collapsible editor columns and a status bar; + neither exists (U7, U8 propose them). +3. `ADMIN.md §5` requires the standing no-token notice and `§2` keeps + infrastructure words to Advanced; today's notice satisfies the first by + breaking the second (U1 proposes a reading that satisfies both). +4. `ADMIN.md §10` says the deploy explanation is "at the top" of the + Plugins page; U11 keeps it there in one sentence. Moving it lower would + need that section changed first. +5. `CONVENTIONS.md` still gives the first-load budget as 150 KB. + +Open questions: + +1. D4's `select` choices: is a value/label form of `choices` wanted, and in + which contract version? +2. Should Traditional Chinese (`zh-TW`) be planned for? It is a catalog, + but the fallback chain (`zh-TW` → `zh-CN` or → `en`) is a decision. +3. D6: should the operator's notification email follow `ui_locale` once it + exists? +4. Does the CLI get translated messages? This plan assumes not. +5. Is the Chinese documentation's glossary (`docs/zh-CN/`) the source for + interface terms, or does the interface set them? + +## 10. Not in this plan + +- Translating content, starter content or the public themes' packs. +- Right-to-left interface languages. +- A translation management service; catalogs are files in the repository. +- Search, a navigation editor, revision history, or any other feature + `ADMIN.md` describes and the admin lacks. +- Visual-regression tooling. diff --git a/docs/README.md b/docs/README.md index 86b6f09..1e95b45 100644 --- a/docs/README.md +++ b/docs/README.md @@ -36,6 +36,7 @@ rest are the contracts for individual subsystems. | [ADMIN.md](ADMIN.md) | Admin information architecture, the setup wizard, the content editor, the schema-driven form generator, the media library, the quality gates | | [CLI.md](CLI.md) | Commands, arguments, authentication, idempotence rules, exit codes, error-message rules | | [SEO_PERFORMANCE.md](SEO_PERFORMANCE.md) | The SEO output built into the core, hreflang, structured data, the performance budget and how it is measured | +| [ADMIN_I18N_AND_UI.md](ADMIN_I18N_AND_UI.md) | Proposal: a selectable interface language for the admin and the setup wizard (English and Simplified Chinese first), the measured cost of the candidate libraries, how theme, plugin and Worker strings are covered, and a page-by-page review of the admin's interface with the decisions left to the owner | | [SECURITY.md](SECURITY.md) | Trust levels, credential handling and the encryption format, authentication, sanitisation, upload validation, error hygiene, and **what is deliberately not defended against** | ## Process documents From fbee452f93d89a3ad28477f3987c99c9a2cdc955 Mon Sep 17 00:00:00 2001 From: JasonYv <233965174+JasonYv@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:31:07 -0800 Subject: [PATCH 04/38] feat(admin): choose the interface language before signing in, and format in it The sign-in page and the setup wizard get a language control, a native select so the first load stays small. src/admin/format.ts formats numbers, dates and durations in the interface language; the account page, the advanced settings and the saved note use it, and the hand-built "N minutes" plural becomes Intl's unit format. admin first load: 165.5 KiB gzip (budget 170) Co-Authored-By: Claude Opus 5.5 --- docs/ADMIN_I18N_AND_UI.md | 11 +++-- src/admin/components/language-picker.tsx | 54 ++++++++++++++++++++++++ src/admin/components/saved-note.tsx | 18 ++------ src/admin/format.ts | 44 +++++++++++++++++++ src/admin/locales/en.po | 1 + src/admin/locales/zh-CN.po | 1 + src/admin/pages/account.tsx | 9 ++-- src/admin/pages/login.tsx | 5 ++- src/admin/pages/settings-advanced.tsx | 3 +- src/admin/pages/setup.tsx | 11 +++-- test/admin/format.test.ts | 28 ++++++++++++ test/e2e/20-interface-language.spec.ts | 14 ++++++ 12 files changed, 172 insertions(+), 27 deletions(-) create mode 100644 src/admin/components/language-picker.tsx create mode 100644 src/admin/format.ts create mode 100644 test/admin/format.test.ts diff --git a/docs/ADMIN_I18N_AND_UI.md b/docs/ADMIN_I18N_AND_UI.md index 03cce21..f439e5f 100644 --- a/docs/ADMIN_I18N_AND_UI.md +++ b/docs/ADMIN_I18N_AND_UI.md @@ -530,9 +530,14 @@ Phase 1 as built: radio group is now named by its label, which `16-appearance` relied on not needing — its selector changed and says why. - `playwright.config.ts` pins `locale: 'en-US'`. -- Not yet done from phase 1's list: the language control on the sign-in - page and in the wizard (the sign-in page already follows the browser), and - the formatter module of §5.4. Both land at the start of phase 2. +- Finished at the start of phase 2: a language control (a native + ``: these screens are on the first load, and a menu + * component would cost more than the choice is worth. + */ + +import { useLingui } from '@lingui/react/macro'; +import { Languages } from 'lucide-react'; +import type { JSX } from 'react'; +import { + NativeSelect, + NativeSelectOption, +} from '@/components/ui/native-select'; +import { + INTERFACE_LANGUAGES, + type InterfaceLanguage, + setInterfaceLanguage, + useInterfaceLanguage, +} from '../i18n.js'; + +export function LanguagePicker({ + className, +}: { + readonly className?: string; +}): JSX.Element { + const language = useInterfaceLanguage(); + const { t } = useLingui(); + return ( +
+
+ ); +} diff --git a/src/admin/components/saved-note.tsx b/src/admin/components/saved-note.tsx index cf767d7..59e01b9 100644 --- a/src/admin/components/saved-note.tsx +++ b/src/admin/components/saved-note.tsx @@ -10,22 +10,10 @@ import { Clock } from 'lucide-react'; import type { JSX } from 'react'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; +import { formatDuration } from '../format.js'; import { useLiveDelay } from '../queries.js'; import { Code, StatusBadge } from './page.js'; -/** Human-readable form of a cache lifetime. */ -function humanize(seconds: number): string { - if (seconds >= 3600) { - const hours = Math.round(seconds / 3600); - return `${hours} hour${hours === 1 ? '' : 's'}`; - } - if (seconds >= 60) { - const minutes = Math.round(seconds / 60); - return `${minutes} minute${minutes === 1 ? '' : 's'}`; - } - return `${seconds} seconds`; -} - export function SavedNote(): JSX.Element { const delay = useLiveDelay(); if (delay.instant) { @@ -36,7 +24,7 @@ export function SavedNote(): JSX.Element { tone="warn" title="Configure a cache-purge token to make saves appear immediately." > - Saved — visitors see it within {humanize(delay.seconds)} + Saved — visitors see it within {formatDuration(delay.seconds)} ); } @@ -57,7 +45,7 @@ export function PurgeNotice(): JSX.Element | null { - Changes reach visitors within {humanize(delay.seconds)} + Changes reach visitors within {formatDuration(delay.seconds)}

diff --git a/src/admin/format.ts b/src/admin/format.ts new file mode 100644 index 0000000..b4a6b31 --- /dev/null +++ b/src/admin/format.ts @@ -0,0 +1,44 @@ +/** + * Numbers, dates and durations in the interface language + * (docs/ADMIN_I18N_AND_UI.md §5.4). + * + * Every formatter the admin uses goes through here, so none of them falls + * back to the browser's own locale or to a hard-coded `'en'`. Plurals of a + * unit ("1 minute", "2 minutes") come from `Intl` too, not from code. + */ + +import { i18n } from '@lingui/core'; + +/** A count, grouped the way the interface language groups digits. */ +export function formatNumber( + value: number, + options?: Intl.NumberFormatOptions, +): string { + return new Intl.NumberFormat(i18n.locale, options).format(value); +} + +/** A moment, with date and time. */ +export function formatDateTime(value: Date | string | number): string { + return new Intl.DateTimeFormat(i18n.locale, { + dateStyle: 'medium', + timeStyle: 'short', + }).format(new Date(value)); +} + +/** + * A length of time in whole units: hours from an hour up, minutes from a + * minute up, seconds below that. + */ +export function formatDuration(seconds: number): string { + const [unit, amount] = + seconds >= 3600 + ? (['hour', Math.round(seconds / 3600)] as const) + : seconds >= 60 + ? (['minute', Math.round(seconds / 60)] as const) + : (['second', seconds] as const); + return new Intl.NumberFormat(i18n.locale, { + style: 'unit', + unit, + unitDisplay: 'long', + }).format(amount); +} diff --git a/src/admin/locales/en.po b/src/admin/locales/en.po index 03b3e10..da36870 100644 --- a/src/admin/locales/en.po +++ b/src/admin/locales/en.po @@ -51,6 +51,7 @@ msgid "Email" msgstr "Email" #: src/admin/components/account-menu.tsx +#: src/admin/components/language-picker.tsx msgid "Interface language" msgstr "Interface language" diff --git a/src/admin/locales/zh-CN.po b/src/admin/locales/zh-CN.po index d40fd66..fb75852 100644 --- a/src/admin/locales/zh-CN.po +++ b/src/admin/locales/zh-CN.po @@ -51,6 +51,7 @@ msgid "Email" msgstr "邮箱" #: src/admin/components/account-menu.tsx +#: src/admin/components/language-picker.tsx msgid "Interface language" msgstr "界面语言" diff --git a/src/admin/pages/account.tsx b/src/admin/pages/account.tsx index a7b1265..c058d57 100644 --- a/src/admin/pages/account.tsx +++ b/src/admin/pages/account.tsx @@ -35,6 +35,7 @@ import { } from '../components/page.js'; import { invalid, showServerErrors } from '../form/form.js'; import { REQUIRED_MESSAGE } from '../form/types.js'; +import { formatNumber } from '../format.js'; import { notify, useReportError } from '../notice.js'; import { keys, useSession } from '../queries.js'; import { @@ -130,11 +131,11 @@ export function AccountPage(): JSX.Element {

Passwords are hashed with PBKDF2-SHA256 at{' '} - {activeSession.passwordIterations.toLocaleString()} iterations. + {formatNumber(activeSession.passwordIterations)} iterations. Current guidance is{' '} - {activeSession.passwordRecommendedIterations.toLocaleString()}, - but a sign-in has to finish inside the Cloudflare Free plan's 10 - ms CPU budget, so the cost is capped. + {formatNumber(activeSession.passwordRecommendedIterations)}, but a + sign-in has to finish inside the Cloudflare Free plan's 10 ms CPU + budget, so the cost is capped.

Use a long, unique password. For stronger protection, put diff --git a/src/admin/pages/login.tsx b/src/admin/pages/login.tsx index 422e0e9..601d019 100644 --- a/src/admin/pages/login.tsx +++ b/src/admin/pages/login.tsx @@ -30,6 +30,7 @@ import { } from '@/components/ui/field'; import { Input } from '@/components/ui/input'; import { ApiError } from '../api.js'; +import { LanguagePicker } from '../components/language-picker.js'; import { invalid } from '../form/form.js'; import { REQUIRED_MESSAGE } from '../form/types.js'; import { signIn, useKnownSettings } from '../queries.js'; @@ -63,7 +64,9 @@ export function LoginPage(): JSX.Element { }); return ( -

+
+ {/* Before a session the language is chosen here (D7). */} + diff --git a/src/admin/pages/settings-advanced.tsx b/src/admin/pages/settings-advanced.tsx index adbae0c..fc6db87 100644 --- a/src/admin/pages/settings-advanced.tsx +++ b/src/admin/pages/settings-advanced.tsx @@ -23,6 +23,7 @@ import { StatusBadge, } from '../components/page.js'; import type { ExportProgress } from '../export.js'; +import { formatDateTime } from '../format.js'; import { notify, useReportError } from '../notice.js'; import { healthQuery, keys, saveSettings, useSettings } from '../queries.js'; @@ -228,7 +229,7 @@ export function AdvancedPage(): JSX.Element { 'Last failed purge',
- {new Date(purgeFailure.at).toLocaleString()} — after{' '} + {formatDateTime(purgeFailure.at)} — after{' '} {describePurgeSource(purgeFailure.source)} {purgeFailure.status === undefined ? ', Cloudflare could not be reached' diff --git a/src/admin/pages/setup.tsx b/src/admin/pages/setup.tsx index b9f0a2f..6bbaf67 100644 --- a/src/admin/pages/setup.tsx +++ b/src/admin/pages/setup.tsx @@ -26,6 +26,7 @@ import { import { Input } from '@/components/ui/input'; import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'; import { ApiError, api, setCsrf } from '../api.js'; +import { LanguagePicker } from '../components/language-picker.js'; import { Code, Section } from '../components/page.js'; import { keys } from '../queries.js'; @@ -197,9 +198,13 @@ export function SetupPage(): JSX.Element {
-

- Set up your site -

+
+

+ Set up your site +

+ {/* The interface language, not the site's languages (D7). */} + +
    {steps.map((entry, index) => (
  1. { + afterAll(() => { + i18n.activate('en'); + }); + + it('writes durations in English with the right plural', () => { + i18n.loadAndActivate({ locale: 'en', messages: {} }); + expect(formatDuration(60)).toBe('1 minute'); + expect(formatDuration(300)).toBe('5 minutes'); + expect(formatDuration(7200)).toBe('2 hours'); + expect(formatDuration(30)).toBe('30 seconds'); + }); + + it('writes durations and numbers in Simplified Chinese', () => { + i18n.loadAndActivate({ locale: 'zh-CN', messages: {} }); + expect(formatDuration(300)).toBe('5分钟'); + expect(formatNumber(600000)).toBe('600,000'); + }); +}); diff --git a/test/e2e/20-interface-language.spec.ts b/test/e2e/20-interface-language.spec.ts index 159baf2..d8b02a3 100644 --- a/test/e2e/20-interface-language.spec.ts +++ b/test/e2e/20-interface-language.spec.ts @@ -52,3 +52,17 @@ test.describe('a browser that prefers Chinese', () => { await expect(page.locator('html')).toHaveAttribute('lang', 'zh-CN'); }); }); + +test('can be chosen on the sign-in page, before there is a session', async ({ + page, +}) => { + await page.goto('/_mallok/app/'); + await page + .getByRole('combobox', { name: 'Interface language' }) + .selectOption('zh-CN'); + await expect(page.getByRole('heading', { name: '登录' })).toBeVisible(); + await expect(page.locator('html')).toHaveAttribute('lang', 'zh-CN'); + + await page.getByRole('combobox', { name: '界面语言' }).selectOption('en'); + await expect(page.getByRole('heading', { name: 'Sign in' })).toBeVisible(); +}); From bb278c75a68d5bed0b077e2ba8174300640a10f7 Mon Sep 17 00:00:00 2001 From: JasonYv <233965174+JasonYv@users.noreply.github.com> Date: Fri, 13 Nov 2026 10:45:16 -0800 Subject: [PATCH 05/38] feat(admin): translate the settings pages into Simplified Chinese Site, Appearance, Email and Advanced, and the saved note and standing purge notice they share. Fields a page declares itself are built in the interface language; counts go through plurals ("1 URL moved"); the cause of a failed purge is joined with Intl.ListFormat; storage counts get labels instead of the Worker's keys. The two window.confirm prompts are messages too. The core Vitest project compiles Lingui macros, since test/admin imports these pages; redeploy-notice reads the instant/deploy lists as messages. Still English here: labels a theme declares (D4), the form controls' own words (end of phase 2) and text the Worker sends (D3). admin first load: 165.3 KiB gzip (budget 170) Co-Authored-By: Claude Opus 5.5 --- src/admin/components/saved-note.tsx | 26 +- src/admin/locales/en.po | 543 ++++++++++++++++++++++++ src/admin/locales/zh-CN.po | 543 ++++++++++++++++++++++++ src/admin/pages/settings-advanced.tsx | 234 ++++++---- src/admin/pages/settings-appearance.tsx | 62 ++- src/admin/pages/settings-email.tsx | 77 ++-- src/admin/pages/settings-site.tsx | 145 ++++--- test/admin/redeploy-notice.test.ts | 11 +- vitest.config.ts | 13 +- 9 files changed, 1437 insertions(+), 217 deletions(-) diff --git a/src/admin/components/saved-note.tsx b/src/admin/components/saved-note.tsx index 59e01b9..d1df095 100644 --- a/src/admin/components/saved-note.tsx +++ b/src/admin/components/saved-note.tsx @@ -7,6 +7,7 @@ * (docs/ADMIN.md §5, docs/ARCHITECTURE.md §6.2). */ +import { Trans, useLingui } from '@lingui/react/macro'; import { Clock } from 'lucide-react'; import type { JSX } from 'react'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; @@ -16,15 +17,21 @@ import { Code, StatusBadge } from './page.js'; export function SavedNote(): JSX.Element { const delay = useLiveDelay(); + const { t } = useLingui(); if (delay.instant) { - return Saved — live now; + return ( + + Saved — live now + + ); } + const within = formatDuration(delay.seconds); return ( - Saved — visitors see it within {formatDuration(delay.seconds)} + Saved — visitors see it within {within} ); } @@ -39,20 +46,23 @@ export function PurgeNotice(): JSX.Element | null { if (delay.instant) { return null; } + const within = formatDuration(delay.seconds); return ( // A standing note, not an alert: it is true from the first render until // someone configures the token, and must not interrupt a screen reader. - Changes reach visitors within {formatDuration(delay.seconds)} + Changes reach visitors within {within}

    - No cache-purge token is configured, so a saved change reaches visitors - only after the cached page expires. This is a working site, not a - broken one — add CF_API_TOKEN and CF_ZONE_ID{' '} - as Worker secrets to get instant publishing. + + No cache-purge token is configured, so a saved change reaches + visitors only after the cached page expires. This is a working site, + not a broken one — add CF_API_TOKEN and{' '} + CF_ZONE_ID as Worker secrets to get instant publishing. +

    diff --git a/src/admin/locales/en.po b/src/admin/locales/en.po index da36870..214382a 100644 --- a/src/admin/locales/en.po +++ b/src/admin/locales/en.po @@ -7,6 +7,56 @@ msgstr "" "X-Generator: @lingui/cli\n" "Language: en\n" +#. placeholder {0}: progress.done +#. placeholder {1}: progress.total +#: src/admin/pages/settings-advanced.tsx +msgid "{0}/{1} files" +msgstr "{0}/{1} files" + +#: src/admin/pages/settings-advanced.tsx +msgid "{items, plural, one {# item} other {# items}} and {files, plural, one {# file} other {# files}} in {fileName}." +msgstr "{items, plural, one {# item} other {# items}} and {files, plural, one {# file} other {# files}} in {fileName}." + +#: src/admin/pages/settings-appearance.tsx +msgid "{locale} (default)" +msgstr "{locale} (default)" + +#: src/admin/pages/settings-site.tsx +msgid "{moved, plural, one {# URL moved, with a redirect; navigation links rewritten.} other {# URLs moved, each with a redirect; navigation links rewritten.}}" +msgstr "{moved, plural, one {# URL moved, with a redirect; navigation links rewritten.} other {# URLs moved, each with a redirect; navigation links rewritten.}}" + +#: src/admin/pages/settings-appearance.tsx +msgid "{scripts, plural, one {Injects # script} other {Injects # scripts}}" +msgstr "{scripts, plural, one {Injects # script} other {Injects # scripts}}" + +#: src/admin/pages/settings-advanced.tsx +msgid "{when} — after {cause}, Cloudflare answered HTTP {status}" +msgstr "{when} — after {cause}, Cloudflare answered HTTP {status}" + +#: src/admin/pages/settings-advanced.tsx +msgid "{when} — after {cause}, Cloudflare could not be reached" +msgstr "{when} — after {cause}, Cloudflare could not be reached" + +#: src/admin/pages/settings-advanced.tsx +msgid "a content change" +msgstr "a content change" + +#: src/admin/pages/settings-advanced.tsx +msgid "a plugin switch" +msgstr "a plugin switch" + +#: src/admin/pages/settings-advanced.tsx +msgid "a scheduled publication" +msgstr "a scheduled publication" + +#: src/admin/pages/settings-advanced.tsx +msgid "a settings change" +msgstr "a settings change" + +#: src/admin/pages/settings-advanced.tsx +msgid "A zip containing every page as Markdown, its images, your settings and your inquiries. It is a complete site you can read anywhere — take it to Astro, Hugo or Obsidian whenever you like. Export before upgrading." +msgstr "A zip containing every page as Markdown, its images, your settings and your inquiries. It is a complete site you can read anywhere — take it to Astro, Hugo or Obsidian whenever you like. Export before upgrading." + #: src/admin/components/account-menu.tsx #: src/admin/components/shell.tsx msgid "Account" @@ -21,72 +71,460 @@ msgstr "Account and API tokens" msgid "Account menu" msgstr "Account menu" +#: src/admin/pages/settings-advanced.tsx +msgid "Active" +msgstr "Active" + +#: src/admin/pages/settings-site.tsx +msgid "Add language" +msgstr "Add language" + #: src/admin/components/shell.tsx +#: src/admin/pages/settings-advanced.tsx msgid "Advanced" msgstr "Advanced" +#: src/admin/pages/settings-site.tsx +msgid "An R2 custom domain, e.g. https://media.example.com. Empty serves images through the Worker." +msgstr "An R2 custom domain, e.g. https://media.example.com. Empty serves images through the Worker." + #: src/admin/components/shell.tsx +#: src/admin/pages/settings-appearance.tsx msgid "Appearance" msgstr "Appearance" +#: src/admin/pages/settings-advanced.tsx +msgid "Applied migrations" +msgstr "Applied migrations" + +#: src/admin/pages/settings-appearance.tsx +msgid "Assets" +msgstr "Assets" + +#: src/admin/pages/settings-advanced.tsx +msgid "Background jobs waiting" +msgstr "Background jobs waiting" + +#: src/admin/pages/settings-advanced.tsx +msgid "Backup and export" +msgstr "Backup and export" + +#: src/admin/pages/settings-advanced.tsx +msgid "Building…" +msgstr "Building…" + +#: src/admin/pages/settings-appearance.tsx +msgid "Built into this deployment: {builtIn}. Your content, its ids and every URL stay exactly as they are." +msgstr "Built into this deployment: {builtIn}. Your content, its ids and every URL stay exactly as they are." + +#: src/admin/pages/settings-advanced.tsx +msgid "Cache" +msgstr "Cache" + +#: src/admin/pages/settings-advanced.tsx +msgid "Cache purge token" +msgstr "Cache purge token" + +#: src/admin/components/saved-note.tsx +msgid "Changes reach visitors within {within}" +msgstr "Changes reach visitors within {within}" + +#: src/admin/pages/settings-advanced.tsx +msgid "Changing anything else in the source tree" +msgstr "Changing anything else in the source tree" + +#: src/admin/pages/settings-appearance.tsx +msgid "Changing the theme takes a deploy" +msgstr "Changing the theme takes a deploy" + +#: src/admin/pages/settings-email.tsx +msgid "Checking…" +msgstr "Checking…" + +#: src/admin/pages/settings-advanced.tsx +msgid "Clear cached pages" +msgstr "Clear cached pages" + +#: src/admin/pages/settings-advanced.tsx +msgid "Cleared the fragment cache." +msgstr "Cleared the fragment cache." + +#: src/admin/pages/settings-advanced.tsx +msgid "Cleared the page cache." +msgstr "Cleared the page cache." + +#: src/admin/pages/settings-advanced.tsx +msgid "Clearing caches" +msgstr "Clearing caches" + +#: src/admin/pages/settings-advanced.tsx +msgid "clearing the fragment cache" +msgstr "clearing the fragment cache" + +#: src/admin/pages/settings-advanced.tsx +msgid "Clearing…" +msgstr "Clearing…" + +#: src/admin/pages/settings-appearance.tsx +msgid "Client JavaScript" +msgstr "Client JavaScript" + #: src/admin/components/account-menu.tsx msgid "Colour scheme" msgstr "Colour scheme" +#: src/admin/components/saved-note.tsx +msgid "Configure a cache-purge token to make saves appear immediately." +msgstr "Configure a cache-purge token to make saves appear immediately." + +#: src/admin/pages/settings-advanced.tsx +msgid "Configured" +msgstr "Configured" + #: src/admin/components/shell.tsx msgid "Content" msgstr "Content" +#: src/admin/pages/settings-advanced.tsx +msgid "Content items" +msgstr "Content items" + +#: src/admin/pages/settings-appearance.tsx +msgid "Content types" +msgstr "Content types" + +#: src/admin/pages/settings-advanced.tsx +msgid "Content: create, edit, publish, delete" +msgstr "Content: create, edit, publish, delete" + +#: src/admin/pages/settings-advanced.tsx +msgid "Could not load diagnostics." +msgstr "Could not load diagnostics." + +#: src/admin/pages/settings-advanced.tsx +#: src/admin/pages/settings-appearance.tsx +#: src/admin/pages/settings-email.tsx +#: src/admin/pages/settings-site.tsx +msgid "Could not save." +msgstr "Could not save." + +#: src/admin/pages/settings-site.tsx +msgid "Could not switch." +msgstr "Could not switch." + +#: src/admin/pages/settings-advanced.tsx +#: src/admin/pages/settings-site.tsx +msgid "Custom domain" +msgstr "Custom domain" + #: src/admin/components/account-menu.tsx msgid "Dark" msgstr "Dark" +#: src/admin/pages/settings-site.tsx +msgid "Default" +msgstr "Default" + +#: src/admin/pages/settings-site.tsx +msgid "Default language is now \"{locale}\". {moved, plural, one {# URL moved, with a redirect.} other {# URLs moved, each with a redirect.}}" +msgstr "Default language is now \"{locale}\". {moved, plural, one {# URL moved, with a redirect.} other {# URLs moved, each with a redirect.}}" + +#: src/admin/pages/settings-advanced.tsx +msgid "Diagnostics" +msgstr "Diagnostics" + +#: src/admin/pages/settings-advanced.tsx +msgid "Edge cache" +msgstr "Edge cache" + +#: src/admin/pages/settings-advanced.tsx +msgid "Edge cache lifetime (seconds)" +msgstr "Edge cache lifetime (seconds)" + #: src/admin/components/shell.tsx msgid "Edit" msgstr "Edit" +#: src/admin/pages/settings-appearance.tsx +msgid "Editing" +msgstr "Editing" + #: src/admin/components/shell.tsx #: src/admin/pages/login.tsx +#: src/admin/pages/settings-email.tsx msgid "Email" msgstr "Email" +#: src/admin/pages/settings-advanced.tsx +msgid "Email (Resend)" +msgstr "Email (Resend)" + +#: src/admin/pages/settings-site.tsx +msgid "Every language is served under <0>//, the default one too; the site's root redirects to <1>/{prefix}." +msgstr "Every language is served under <0>//, the default one too; the site's root redirects to <1>/{prefix}." + +#: src/admin/pages/settings-advanced.tsx +msgid "Everything below is a platform detail. You do not need any of it to run the site." +msgstr "Everything below is a platform detail. You do not need any of it to run the site." + +#: src/admin/pages/settings-advanced.tsx +msgid "Export everything" +msgstr "Export everything" + +#: src/admin/pages/settings-advanced.tsx +msgid "Failed background jobs" +msgstr "Failed background jobs" + +#: src/admin/pages/settings-email.tsx +msgid "From address" +msgstr "From address" + +#: src/admin/pages/settings-advanced.tsx +msgid "Inactive — a workers.dev URL is a preview, not a site" +msgstr "Inactive — a workers.dev URL is a preview, not a site" + +#: src/admin/pages/settings-advanced.tsx +msgid "Installing, updating or removing a plugin" +msgstr "Installing, updating or removing a plugin" + +#: src/admin/pages/settings-advanced.tsx +msgid "Instant" +msgstr "Instant" + #: src/admin/components/account-menu.tsx #: src/admin/components/language-picker.tsx msgid "Interface language" msgstr "Interface language" +#: src/admin/pages/settings-advanced.tsx +msgid "Key set, no site sender — only plugins with their own send" +msgstr "Key set, no site sender — only plugins with their own send" + +#: src/admin/pages/settings-site.tsx +msgid "Language code" +msgstr "Language code" + +#: src/admin/pages/settings-site.tsx +msgid "Languages" +msgstr "Languages" + +#: src/admin/pages/settings-advanced.tsx +msgid "Last failed purge" +msgstr "Last failed purge" + #: src/admin/components/account-menu.tsx msgid "Light" msgstr "Light" +#: src/admin/pages/settings-advanced.tsx +msgid "Loading…" +msgstr "Loading…" + +#: src/admin/pages/settings-site.tsx +msgid "Make \"{locale}\" the default language?\n" +"\n" +"Every public URL is rewritten and the old URLs are redirected. This cannot be undone automatically." +msgstr "Make \"{locale}\" the default language?\n" +"\n" +"Every public URL is rewritten and the old URLs are redirected. This cannot be undone automatically." + +#: src/admin/pages/settings-site.tsx +msgid "Make default" +msgstr "Make default" + #: src/admin/components/shell.tsx msgid "Media" msgstr "Media" +#: src/admin/pages/settings-advanced.tsx +#: src/admin/pages/settings-site.tsx +msgid "Media domain" +msgstr "Media domain" + +#: src/admin/pages/settings-advanced.tsx +msgid "Media files" +msgstr "Media files" + +#: src/admin/pages/settings-email.tsx +msgid "Must be on a domain you have verified in Resend. A plugin may set its own sender; this one is used whenever it does not." +msgstr "Must be on a domain you have verified in Resend. A plugin may set its own sender; this one is used whenever it does not." + +#: src/admin/pages/settings-advanced.tsx +msgid "Needs a rebuild and deploy" +msgstr "Needs a rebuild and deploy" + +#: src/admin/pages/settings-advanced.tsx +msgid "Neither of these loses anything. Cached pages and fragments are both derived from your content and are rebuilt on the next request — the only cost is that the next visitor waits for a render." +msgstr "Neither of these loses anything. Cached pages and fragments are both derived from your content and are rebuilt on the next request — the only cost is that the next visitor waits for a render." + #: src/admin/components/shell.tsx msgid "New item" msgstr "New item" +#: src/admin/components/saved-note.tsx +msgid "No cache-purge token is configured, so a saved change reaches visitors only after the cached page expires. This is a working site, not a broken one — add <0>CF_API_TOKEN and <1>CF_ZONE_ID as Worker secrets to get instant publishing." +msgstr "No cache-purge token is configured, so a saved change reaches visitors only after the cached page expires. This is a working site, not a broken one — add <0>CF_API_TOKEN and <1>CF_ZONE_ID as Worker secrets to get instant publishing." + +#: src/admin/pages/settings-advanced.tsx +msgid "No error was recorded." +msgstr "No error was recorded." + +#: src/admin/pages/settings-advanced.tsx +msgid "No key — no email is sent" +msgstr "No key — no email is sent" + +#: src/admin/pages/settings-appearance.tsx +msgid "None" +msgstr "None" + +#: src/admin/pages/settings-advanced.tsx +msgid "Not bound" +msgstr "Not bound" + +#: src/admin/pages/settings-advanced.tsx +msgid "Not configured — edits go live after the cache expires" +msgstr "Not configured — edits go live after the cache expires" + #: src/admin/components/shell.tsx msgid "Not found" msgstr "Not found" +#: src/admin/pages/settings-email.tsx +msgid "One Resend key and one sender address for the whole site. Every plugin that sends email uses them, and a change applies to the next message — no rebuild, no deploy." +msgstr "One Resend key and one sender address for the whole site. Every plugin that sends email uses them, and a change applies to the next message — no rebuild, no deploy." + +#: src/admin/pages/settings-site.tsx +msgid "Only this host is indexable. Without one, every page is served noindex and the edge cache does not apply." +msgstr "Only this host is indexable. Without one, every page is served noindex and the edge cache does not apply." + +#: src/admin/pages/settings-advanced.tsx +msgid "Pages it named may still be served from the cache until they expire." +msgstr "Pages it named may still be served from the cache until they expire." + #: src/admin/pages/login.tsx msgid "Password" msgstr "Password" +#: src/admin/pages/settings-advanced.tsx +msgid "Plugin on/off switches, settings and secrets" +msgstr "Plugin on/off switches, settings and secrets" + #: src/admin/components/shell.tsx msgid "Plugins" msgstr "Plugins" +#: src/admin/pages/settings-site.tsx +msgid "Prefix the default language too (<0>/{prefix}/…)" +msgstr "Prefix the default language too (<0>/{prefix}/…)" + +#: src/admin/pages/settings-advanced.tsx +msgid "Published" +msgstr "Published" + +#: src/admin/pages/settings-advanced.tsx +msgid "Rebuild all pages" +msgstr "Rebuild all pages" + +#: src/admin/pages/settings-advanced.tsx +msgid "Redirects" +msgstr "Redirects" + +#: src/admin/pages/settings-site.tsx +msgid "Remove" +msgstr "Remove" + +#: src/admin/pages/settings-advanced.tsx +msgid "Render pipeline" +msgstr "Render pipeline" + +#: src/admin/pages/settings-advanced.tsx +msgid "Rendered fragments" +msgstr "Rendered fragments" + +#: src/admin/pages/settings-email.tsx +msgid "Resend API key" +msgstr "Resend API key" + #: src/admin/components/account-menu.tsx msgid "Same as the system" msgstr "Same as the system" +#: src/admin/pages/settings-advanced.tsx +#: src/admin/pages/settings-site.tsx +msgid "Save" +msgstr "Save" + +#: src/admin/pages/settings-appearance.tsx +msgid "Save options" +msgstr "Save options" + +#: src/admin/pages/settings-email.tsx +msgid "Save sender" +msgstr "Save sender" + +#: src/admin/pages/settings-email.tsx +msgid "Saved" +msgstr "Saved" + +#: src/admin/components/saved-note.tsx +msgid "Saved — live now" +msgstr "Saved — live now" + +#: src/admin/components/saved-note.tsx +msgid "Saved — visitors see it within {within}" +msgstr "Saved — visitors see it within {within}" + +#: src/admin/pages/settings-advanced.tsx +msgid "Saving content purges the pages it affects, so this is a ceiling for pages nothing touched — not the delay before an edit appears." +msgstr "Saving content purges the pages it affects, so this is a ceiling for pages nothing touched — not the delay before an edit appears." + +#: src/admin/pages/settings-advanced.tsx +#: src/admin/pages/settings-appearance.tsx +#: src/admin/pages/settings-email.tsx +#: src/admin/pages/settings-site.tsx +msgid "Saving…" +msgstr "Saving…" + +#: src/admin/pages/settings-email.tsx +msgid "Sender" +msgstr "Sender" + +#: src/admin/pages/settings-site.tsx +msgid "Serve \"{prefix}\" at the root again?\n" +"\n" +"Every URL of the default language moves (/{prefix}/about becomes /about) and each old URL, lists, tags and /{prefix} included, redirects to its new one. The navigation's links to this site are rewritten to match." +msgstr "Serve \"{prefix}\" at the root again?\n" +"\n" +"Every URL of the default language moves (/{prefix}/about becomes /about) and each old URL, lists, tags and /{prefix} included, redirects to its new one. The navigation's links to this site are rewritten to match." + +#: src/admin/pages/settings-site.tsx +msgid "Serve \"{prefix}\" under /{prefix}/ too?\n" +"\n" +"Every URL of the default language moves (/about becomes /{prefix}/about) and each old URL, lists and tags included, redirects to its new one. The navigation's links to this site are rewritten to match. The site's root then only redirects to /{prefix}." +msgstr "Serve \"{prefix}\" under /{prefix}/ too?\n" +"\n" +"Every URL of the default language moves (/about becomes /{prefix}/about) and each old URL, lists and tags included, redirects to its new one. The navigation's links to this site are rewritten to match. The site's root then only redirects to /{prefix}." + +#: src/admin/pages/settings-advanced.tsx +msgid "Served through the Worker" +msgstr "Served through the Worker" + #: src/admin/components/shell.tsx msgid "Settings" msgstr "Settings" +#: src/admin/pages/settings-advanced.tsx +msgid "setup" +msgstr "setup" + +#: src/admin/pages/settings-site.tsx +msgid "Shown by most themes under the site name, and as the home page description." +msgstr "Shown by most themes under the site name, and as the home page description." + +#: src/admin/pages/settings-site.tsx +msgid "Shown on pages in {locale}. Empty uses the tagline above." +msgstr "Shown on pages in {locale}. Empty uses the tagline above." + #: src/admin/pages/login.tsx msgid "Sign in" msgstr "Sign in" @@ -104,9 +542,114 @@ msgid "Signing in…" msgstr "Signing in…" #: src/admin/components/shell.tsx +#: src/admin/pages/settings-site.tsx msgid "Site" msgstr "Site" +#: src/admin/pages/settings-site.tsx +msgid "Site name" +msgstr "Site name" + +#: src/admin/pages/settings-advanced.tsx +msgid "Site settings, languages, navigation" +msgstr "Site settings, languages, navigation" + +#: src/admin/pages/settings-advanced.tsx +msgid "Storage" +msgstr "Storage" + +#: src/admin/pages/settings-email.tsx +msgid "Stored encrypted. It is never shown again, here or anywhere else." +msgstr "Stored encrypted. It is never shown again, here or anywhere else." + +#: src/admin/pages/settings-advanced.tsx +msgid "Switching to a different theme" +msgstr "Switching to a different theme" + +#: src/admin/pages/settings-site.tsx +msgid "Tagline" +msgstr "Tagline" + +#: src/admin/pages/settings-site.tsx +msgid "Tagline ({locale})" +msgstr "Tagline ({locale})" + +#: src/admin/pages/settings-email.tsx +msgid "Test" +msgstr "Test" + +#: src/admin/pages/settings-advanced.tsx +msgid "That did not work." +msgstr "That did not work." + +#: src/admin/pages/settings-advanced.tsx +msgid "the {plugin} plugin" +msgstr "the {plugin} plugin" + +#: src/admin/pages/settings-email.tsx +msgid "The check failed." +msgstr "The check failed." + +#: src/admin/pages/settings-site.tsx +msgid "The default language has no URL prefix; every other language is served under <0>//." +msgstr "The default language has no URL prefix; every other language is served under <0>//." + +#: src/admin/pages/settings-advanced.tsx +msgid "The export failed." +msgstr "The export failed." + +#: src/admin/pages/settings-appearance.tsx +msgid "The options below are runtime settings: saving takes effect without a rebuild. The theme itself is source code." +msgstr "The options below are runtime settings: saving takes effect without a rebuild. The theme itself is source code." + #: src/admin/pages/login.tsx msgid "The site's admin" msgstr "The site's admin" + +#: src/admin/pages/settings-advanced.tsx +msgid "Theme" +msgstr "Theme" + +#: src/admin/pages/settings-appearance.tsx +msgid "Theme options" +msgstr "Theme options" + +#: src/admin/pages/settings-advanced.tsx +msgid "Theme options this theme declares" +msgstr "Theme options this theme declares" + +#: src/admin/pages/settings-appearance.tsx +msgid "Themes live in the source tree, not the database — they are compiled into the Worker. To switch, edit <0>ACTIVE_THEME in <1>src/themes/index.ts, then build and deploy again." +msgstr "Themes live in the source tree, not the database — they are compiled into the Worker. To switch, edit <0>ACTIVE_THEME in <1>src/themes/index.ts, then build and deploy again." + +#: src/admin/pages/settings-site.tsx +msgid "These are stored the moment you save — no rebuild, no deploy." +msgstr "These are stored the moment you save — no rebuild, no deploy." + +#: src/admin/pages/settings-appearance.tsx +msgid "These values apply to every language unless a language overrides them below." +msgstr "These values apply to every language unless a language overrides them below." + +#: src/admin/pages/settings-advanced.tsx +msgid "Upgrading Mallok itself" +msgstr "Upgrading Mallok itself" + +#: src/admin/pages/settings-email.tsx +msgid "Use an address such as hello@example.com or Acme ." +msgstr "Use an address such as hello@example.com or Acme ." + +#: src/admin/pages/settings-appearance.tsx +msgid "Values you change here apply only to {editingLocale}. Anything you leave alone follows the {editingDefaultLocale} value." +msgstr "Values you change here apply only to {editingLocale}. Anything you leave alone follows the {editingDefaultLocale} value." + +#: src/admin/pages/settings-advanced.tsx +msgid "What is instant, and what needs a deploy" +msgstr "What is instant, and what needs a deploy" + +#: src/admin/pages/settings-email.tsx +msgid "Without a key no email is sent. A message queued meanwhile is retried for about 30 minutes and then marked failed." +msgstr "Without a key no email is sent. A message queued meanwhile is retried for about 30 minutes and then marked failed." + +#: src/admin/pages/settings-advanced.tsx +msgid "Work that was retried and gave up — an email that could not be sent, a plugin's job that kept failing. Nothing here is retried again by itself." +msgstr "Work that was retried and gave up — an email that could not be sent, a plugin's job that kept failing. Nothing here is retried again by itself." diff --git a/src/admin/locales/zh-CN.po b/src/admin/locales/zh-CN.po index fb75852..786ec4b 100644 --- a/src/admin/locales/zh-CN.po +++ b/src/admin/locales/zh-CN.po @@ -7,6 +7,56 @@ msgstr "" "X-Generator: @lingui/cli\n" "Language: zh-CN\n" +#. placeholder {0}: progress.done +#. placeholder {1}: progress.total +#: src/admin/pages/settings-advanced.tsx +msgid "{0}/{1} files" +msgstr "{0}/{1} 个文件" + +#: src/admin/pages/settings-advanced.tsx +msgid "{items, plural, one {# item} other {# items}} and {files, plural, one {# file} other {# files}} in {fileName}." +msgstr "{fileName} 中包含 {items, plural, other {# 项内容}}和 {files, plural, other {# 个文件}}。" + +#: src/admin/pages/settings-appearance.tsx +msgid "{locale} (default)" +msgstr "{locale}(默认)" + +#: src/admin/pages/settings-site.tsx +msgid "{moved, plural, one {# URL moved, with a redirect; navigation links rewritten.} other {# URLs moved, each with a redirect; navigation links rewritten.}}" +msgstr "{moved, plural, other {已迁移 # 个 URL,均已设置重定向;导航链接已同步改写。}}" + +#: src/admin/pages/settings-appearance.tsx +msgid "{scripts, plural, one {Injects # script} other {Injects # scripts}}" +msgstr "{scripts, plural, other {注入 # 个脚本}}" + +#: src/admin/pages/settings-advanced.tsx +msgid "{when} — after {cause}, Cloudflare answered HTTP {status}" +msgstr "{when} — 由{cause}触发,Cloudflare 返回 HTTP {status}" + +#: src/admin/pages/settings-advanced.tsx +msgid "{when} — after {cause}, Cloudflare could not be reached" +msgstr "{when} — 由{cause}触发,无法连接 Cloudflare" + +#: src/admin/pages/settings-advanced.tsx +msgid "a content change" +msgstr "内容修改" + +#: src/admin/pages/settings-advanced.tsx +msgid "a plugin switch" +msgstr "插件开关" + +#: src/admin/pages/settings-advanced.tsx +msgid "a scheduled publication" +msgstr "定时发布" + +#: src/admin/pages/settings-advanced.tsx +msgid "a settings change" +msgstr "设置修改" + +#: src/admin/pages/settings-advanced.tsx +msgid "A zip containing every page as Markdown, its images, your settings and your inquiries. It is a complete site you can read anywhere — take it to Astro, Hugo or Obsidian whenever you like. Export before upgrading." +msgstr "一个 zip 压缩包,包含所有页面的 Markdown、图片、站点设置和询盘。它是一个完整的站点,在哪里都能读取——随时可以带去 Astro、Hugo 或 Obsidian。升级前请先导出。" + #: src/admin/components/account-menu.tsx #: src/admin/components/shell.tsx msgid "Account" @@ -21,72 +71,460 @@ msgstr "账号与 API 令牌" msgid "Account menu" msgstr "账号菜单" +#: src/admin/pages/settings-advanced.tsx +msgid "Active" +msgstr "已生效" + +#: src/admin/pages/settings-site.tsx +msgid "Add language" +msgstr "添加语言" + #: src/admin/components/shell.tsx +#: src/admin/pages/settings-advanced.tsx msgid "Advanced" msgstr "高级" +#: src/admin/pages/settings-site.tsx +msgid "An R2 custom domain, e.g. https://media.example.com. Empty serves images through the Worker." +msgstr "R2 的自定义域名,例如 https://media.example.com。留空则由 Worker 提供图片。" + #: src/admin/components/shell.tsx +#: src/admin/pages/settings-appearance.tsx msgid "Appearance" msgstr "外观" +#: src/admin/pages/settings-advanced.tsx +msgid "Applied migrations" +msgstr "已执行的迁移" + +#: src/admin/pages/settings-appearance.tsx +msgid "Assets" +msgstr "静态资源" + +#: src/admin/pages/settings-advanced.tsx +msgid "Background jobs waiting" +msgstr "等待中的后台任务" + +#: src/admin/pages/settings-advanced.tsx +msgid "Backup and export" +msgstr "备份与导出" + +#: src/admin/pages/settings-advanced.tsx +msgid "Building…" +msgstr "正在生成…" + +#: src/admin/pages/settings-appearance.tsx +msgid "Built into this deployment: {builtIn}. Your content, its ids and every URL stay exactly as they are." +msgstr "本次部署内置的主题:{builtIn}。切换主题后,内容、内容 ID 和所有 URL 都保持不变。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Cache" +msgstr "缓存" + +#: src/admin/pages/settings-advanced.tsx +msgid "Cache purge token" +msgstr "缓存清除令牌" + +#: src/admin/components/saved-note.tsx +msgid "Changes reach visitors within {within}" +msgstr "修改将在 {within}内对访客可见" + +#: src/admin/pages/settings-advanced.tsx +msgid "Changing anything else in the source tree" +msgstr "修改源代码中的其他任何内容" + +#: src/admin/pages/settings-appearance.tsx +msgid "Changing the theme takes a deploy" +msgstr "更换主题需要重新部署" + +#: src/admin/pages/settings-email.tsx +msgid "Checking…" +msgstr "正在检测…" + +#: src/admin/pages/settings-advanced.tsx +msgid "Clear cached pages" +msgstr "清除页面缓存" + +#: src/admin/pages/settings-advanced.tsx +msgid "Cleared the fragment cache." +msgstr "已清除片段缓存。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Cleared the page cache." +msgstr "已清除页面缓存。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Clearing caches" +msgstr "清除缓存" + +#: src/admin/pages/settings-advanced.tsx +msgid "clearing the fragment cache" +msgstr "清除片段缓存" + +#: src/admin/pages/settings-advanced.tsx +msgid "Clearing…" +msgstr "正在清除…" + +#: src/admin/pages/settings-appearance.tsx +msgid "Client JavaScript" +msgstr "前台 JavaScript" + #: src/admin/components/account-menu.tsx msgid "Colour scheme" msgstr "配色" +#: src/admin/components/saved-note.tsx +msgid "Configure a cache-purge token to make saves appear immediately." +msgstr "配置缓存清除令牌后,保存即可立即生效。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Configured" +msgstr "已配置" + #: src/admin/components/shell.tsx msgid "Content" msgstr "内容" +#: src/admin/pages/settings-advanced.tsx +msgid "Content items" +msgstr "内容条目" + +#: src/admin/pages/settings-appearance.tsx +msgid "Content types" +msgstr "内容类型" + +#: src/admin/pages/settings-advanced.tsx +msgid "Content: create, edit, publish, delete" +msgstr "内容:新建、编辑、发布、删除" + +#: src/admin/pages/settings-advanced.tsx +msgid "Could not load diagnostics." +msgstr "无法加载诊断信息。" + +#: src/admin/pages/settings-advanced.tsx +#: src/admin/pages/settings-appearance.tsx +#: src/admin/pages/settings-email.tsx +#: src/admin/pages/settings-site.tsx +msgid "Could not save." +msgstr "保存失败。" + +#: src/admin/pages/settings-site.tsx +msgid "Could not switch." +msgstr "切换失败。" + +#: src/admin/pages/settings-advanced.tsx +#: src/admin/pages/settings-site.tsx +msgid "Custom domain" +msgstr "自定义域名" + #: src/admin/components/account-menu.tsx msgid "Dark" msgstr "深色" +#: src/admin/pages/settings-site.tsx +msgid "Default" +msgstr "默认" + +#: src/admin/pages/settings-site.tsx +msgid "Default language is now \"{locale}\". {moved, plural, one {# URL moved, with a redirect.} other {# URLs moved, each with a redirect.}}" +msgstr "默认语言已改为“{locale}”。{moved, plural, other {已迁移 # 个 URL,均已设置重定向。}}" + +#: src/admin/pages/settings-advanced.tsx +msgid "Diagnostics" +msgstr "诊断" + +#: src/admin/pages/settings-advanced.tsx +msgid "Edge cache" +msgstr "边缘缓存" + +#: src/admin/pages/settings-advanced.tsx +msgid "Edge cache lifetime (seconds)" +msgstr "边缘缓存有效期(秒)" + #: src/admin/components/shell.tsx msgid "Edit" msgstr "编辑" +#: src/admin/pages/settings-appearance.tsx +msgid "Editing" +msgstr "正在编辑" + #: src/admin/components/shell.tsx #: src/admin/pages/login.tsx +#: src/admin/pages/settings-email.tsx msgid "Email" msgstr "邮箱" +#: src/admin/pages/settings-advanced.tsx +msgid "Email (Resend)" +msgstr "邮件(Resend)" + +#: src/admin/pages/settings-site.tsx +msgid "Every language is served under <0>//, the default one too; the site's root redirects to <1>/{prefix}." +msgstr "所有语言(包括默认语言)都在 <0>// 下提供;站点根路径会重定向到 <1>/{prefix}。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Everything below is a platform detail. You do not need any of it to run the site." +msgstr "以下都是平台层面的细节,日常运营站点用不到。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Export everything" +msgstr "全部导出" + +#: src/admin/pages/settings-advanced.tsx +msgid "Failed background jobs" +msgstr "失败的后台任务" + +#: src/admin/pages/settings-email.tsx +msgid "From address" +msgstr "发件地址" + +#: src/admin/pages/settings-advanced.tsx +msgid "Inactive — a workers.dev URL is a preview, not a site" +msgstr "未生效 — workers.dev 地址只是预览,不是正式站点" + +#: src/admin/pages/settings-advanced.tsx +msgid "Installing, updating or removing a plugin" +msgstr "安装、更新或移除插件" + +#: src/admin/pages/settings-advanced.tsx +msgid "Instant" +msgstr "立即生效" + #: src/admin/components/account-menu.tsx #: src/admin/components/language-picker.tsx msgid "Interface language" msgstr "界面语言" +#: src/admin/pages/settings-advanced.tsx +msgid "Key set, no site sender — only plugins with their own send" +msgstr "已设置密钥,但没有站点发件地址 — 只有自带发件地址的插件能发送" + +#: src/admin/pages/settings-site.tsx +msgid "Language code" +msgstr "语言代码" + +#: src/admin/pages/settings-site.tsx +msgid "Languages" +msgstr "语言" + +#: src/admin/pages/settings-advanced.tsx +msgid "Last failed purge" +msgstr "最近一次清除失败" + #: src/admin/components/account-menu.tsx msgid "Light" msgstr "浅色" +#: src/admin/pages/settings-advanced.tsx +msgid "Loading…" +msgstr "正在加载…" + +#: src/admin/pages/settings-site.tsx +msgid "Make \"{locale}\" the default language?\n" +"\n" +"Every public URL is rewritten and the old URLs are redirected. This cannot be undone automatically." +msgstr "将“{locale}”设为默认语言?\n" +"\n" +"所有公开 URL 都会改写,旧 URL 会重定向到新地址。此操作无法自动撤销。" + +#: src/admin/pages/settings-site.tsx +msgid "Make default" +msgstr "设为默认" + #: src/admin/components/shell.tsx msgid "Media" msgstr "媒体" +#: src/admin/pages/settings-advanced.tsx +#: src/admin/pages/settings-site.tsx +msgid "Media domain" +msgstr "媒体域名" + +#: src/admin/pages/settings-advanced.tsx +msgid "Media files" +msgstr "媒体文件" + +#: src/admin/pages/settings-email.tsx +msgid "Must be on a domain you have verified in Resend. A plugin may set its own sender; this one is used whenever it does not." +msgstr "必须是已在 Resend 验证过的域名。插件可以设置自己的发件地址;没有设置时使用这里的地址。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Needs a rebuild and deploy" +msgstr "需要重新构建并部署" + +#: src/admin/pages/settings-advanced.tsx +msgid "Neither of these loses anything. Cached pages and fragments are both derived from your content and are rebuilt on the next request — the only cost is that the next visitor waits for a render." +msgstr "两者都不会丢失任何数据。页面缓存和片段缓存都由内容生成,下一次请求时会重新生成——唯一的代价是下一位访客需要等待一次渲染。" + #: src/admin/components/shell.tsx msgid "New item" msgstr "新建" +#: src/admin/components/saved-note.tsx +msgid "No cache-purge token is configured, so a saved change reaches visitors only after the cached page expires. This is a working site, not a broken one — add <0>CF_API_TOKEN and <1>CF_ZONE_ID as Worker secrets to get instant publishing." +msgstr "尚未配置缓存清除令牌,保存的修改要等页面缓存过期后访客才能看到。站点运行正常,并没有出错——将 <0>CF_API_TOKEN 和 <1>CF_ZONE_ID 添加为 Worker 密钥即可即时发布。" + +#: src/admin/pages/settings-advanced.tsx +msgid "No error was recorded." +msgstr "没有记录到错误信息。" + +#: src/admin/pages/settings-advanced.tsx +msgid "No key — no email is sent" +msgstr "未设置密钥 — 不会发送任何邮件" + +#: src/admin/pages/settings-appearance.tsx +msgid "None" +msgstr "无" + +#: src/admin/pages/settings-advanced.tsx +msgid "Not bound" +msgstr "未绑定" + +#: src/admin/pages/settings-advanced.tsx +msgid "Not configured — edits go live after the cache expires" +msgstr "未配置 — 修改要等缓存过期后才生效" + #: src/admin/components/shell.tsx msgid "Not found" msgstr "未找到" +#: src/admin/pages/settings-email.tsx +msgid "One Resend key and one sender address for the whole site. Every plugin that sends email uses them, and a change applies to the next message — no rebuild, no deploy." +msgstr "整个站点共用一个 Resend 密钥和一个发件地址。所有发送邮件的插件都使用它们,修改后对下一封邮件生效——无需重新构建或部署。" + +#: src/admin/pages/settings-site.tsx +msgid "Only this host is indexable. Without one, every page is served noindex and the edge cache does not apply." +msgstr "只有这个域名会被搜索引擎收录。未设置时,所有页面都带 noindex,且边缘缓存不生效。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Pages it named may still be served from the cache until they expire." +msgstr "涉及的页面在缓存过期前,可能仍会显示旧内容。" + #: src/admin/pages/login.tsx msgid "Password" msgstr "密码" +#: src/admin/pages/settings-advanced.tsx +msgid "Plugin on/off switches, settings and secrets" +msgstr "插件的启用开关、设置和密钥" + #: src/admin/components/shell.tsx msgid "Plugins" msgstr "插件" +#: src/admin/pages/settings-site.tsx +msgid "Prefix the default language too (<0>/{prefix}/…)" +msgstr "默认语言也加前缀(<0>/{prefix}/…)" + +#: src/admin/pages/settings-advanced.tsx +msgid "Published" +msgstr "已发布" + +#: src/admin/pages/settings-advanced.tsx +msgid "Rebuild all pages" +msgstr "重新生成所有页面" + +#: src/admin/pages/settings-advanced.tsx +msgid "Redirects" +msgstr "重定向" + +#: src/admin/pages/settings-site.tsx +msgid "Remove" +msgstr "移除" + +#: src/admin/pages/settings-advanced.tsx +msgid "Render pipeline" +msgstr "渲染管线" + +#: src/admin/pages/settings-advanced.tsx +msgid "Rendered fragments" +msgstr "已渲染片段" + +#: src/admin/pages/settings-email.tsx +msgid "Resend API key" +msgstr "Resend API 密钥" + #: src/admin/components/account-menu.tsx msgid "Same as the system" msgstr "跟随系统" +#: src/admin/pages/settings-advanced.tsx +#: src/admin/pages/settings-site.tsx +msgid "Save" +msgstr "保存" + +#: src/admin/pages/settings-appearance.tsx +msgid "Save options" +msgstr "保存选项" + +#: src/admin/pages/settings-email.tsx +msgid "Save sender" +msgstr "保存发件人" + +#: src/admin/pages/settings-email.tsx +msgid "Saved" +msgstr "已保存" + +#: src/admin/components/saved-note.tsx +msgid "Saved — live now" +msgstr "已保存 — 已生效" + +#: src/admin/components/saved-note.tsx +msgid "Saved — visitors see it within {within}" +msgstr "已保存 — 访客将在 {within}内看到" + +#: src/admin/pages/settings-advanced.tsx +msgid "Saving content purges the pages it affects, so this is a ceiling for pages nothing touched — not the delay before an edit appears." +msgstr "保存内容时会清除受影响页面的缓存,所以这是未被修改页面的缓存上限,而不是修改生效前的等待时间。" + +#: src/admin/pages/settings-advanced.tsx +#: src/admin/pages/settings-appearance.tsx +#: src/admin/pages/settings-email.tsx +#: src/admin/pages/settings-site.tsx +msgid "Saving…" +msgstr "正在保存…" + +#: src/admin/pages/settings-email.tsx +msgid "Sender" +msgstr "发件人" + +#: src/admin/pages/settings-site.tsx +msgid "Serve \"{prefix}\" at the root again?\n" +"\n" +"Every URL of the default language moves (/{prefix}/about becomes /about) and each old URL, lists, tags and /{prefix} included, redirects to its new one. The navigation's links to this site are rewritten to match." +msgstr "让“{prefix}”重新在根路径下提供?\n" +"\n" +"默认语言的所有 URL 都会迁移(/{prefix}/about 变为 /about),每个旧 URL(包括列表页、标签页和 /{prefix})都会重定向到新地址。导航中指向本站的链接会同步改写。" + +#: src/admin/pages/settings-site.tsx +msgid "Serve \"{prefix}\" under /{prefix}/ too?\n" +"\n" +"Every URL of the default language moves (/about becomes /{prefix}/about) and each old URL, lists and tags included, redirects to its new one. The navigation's links to this site are rewritten to match. The site's root then only redirects to /{prefix}." +msgstr "让“{prefix}”也在 /{prefix}/ 下提供?\n" +"\n" +"默认语言的所有 URL 都会迁移(/about 变为 /{prefix}/about),每个旧 URL(包括列表页和标签页)都会重定向到新地址。导航中指向本站的链接会同步改写。之后站点根路径只会重定向到 /{prefix}。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Served through the Worker" +msgstr "由 Worker 提供" + #: src/admin/components/shell.tsx msgid "Settings" msgstr "设置" +#: src/admin/pages/settings-advanced.tsx +msgid "setup" +msgstr "初始设置" + +#: src/admin/pages/settings-site.tsx +msgid "Shown by most themes under the site name, and as the home page description." +msgstr "大多数主题会显示在站点名称下方,并用作首页描述。" + +#: src/admin/pages/settings-site.tsx +msgid "Shown on pages in {locale}. Empty uses the tagline above." +msgstr "显示在 {locale} 页面上。留空则使用上面的标语。" + #: src/admin/pages/login.tsx msgid "Sign in" msgstr "登录" @@ -104,9 +542,114 @@ msgid "Signing in…" msgstr "正在登录…" #: src/admin/components/shell.tsx +#: src/admin/pages/settings-site.tsx msgid "Site" msgstr "站点" +#: src/admin/pages/settings-site.tsx +msgid "Site name" +msgstr "站点名称" + +#: src/admin/pages/settings-advanced.tsx +msgid "Site settings, languages, navigation" +msgstr "站点设置、语言、导航" + +#: src/admin/pages/settings-advanced.tsx +msgid "Storage" +msgstr "存储" + +#: src/admin/pages/settings-email.tsx +msgid "Stored encrypted. It is never shown again, here or anywhere else." +msgstr "加密保存。之后在这里或任何地方都不会再显示。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Switching to a different theme" +msgstr "更换为其他主题" + +#: src/admin/pages/settings-site.tsx +msgid "Tagline" +msgstr "标语" + +#: src/admin/pages/settings-site.tsx +msgid "Tagline ({locale})" +msgstr "标语({locale})" + +#: src/admin/pages/settings-email.tsx +msgid "Test" +msgstr "检测" + +#: src/admin/pages/settings-advanced.tsx +msgid "That did not work." +msgstr "操作未成功。" + +#: src/admin/pages/settings-advanced.tsx +msgid "the {plugin} plugin" +msgstr "{plugin} 插件" + +#: src/admin/pages/settings-email.tsx +msgid "The check failed." +msgstr "检测失败。" + +#: src/admin/pages/settings-site.tsx +msgid "The default language has no URL prefix; every other language is served under <0>//." +msgstr "默认语言不带 URL 前缀;其他语言都在 <0>// 下提供。" + +#: src/admin/pages/settings-advanced.tsx +msgid "The export failed." +msgstr "导出失败。" + +#: src/admin/pages/settings-appearance.tsx +msgid "The options below are runtime settings: saving takes effect without a rebuild. The theme itself is source code." +msgstr "以下选项是运行时设置:保存后立即生效,无需重新构建。主题本身属于源代码。" + #: src/admin/pages/login.tsx msgid "The site's admin" msgstr "站点后台" + +#: src/admin/pages/settings-advanced.tsx +msgid "Theme" +msgstr "主题" + +#: src/admin/pages/settings-appearance.tsx +msgid "Theme options" +msgstr "主题选项" + +#: src/admin/pages/settings-advanced.tsx +msgid "Theme options this theme declares" +msgstr "当前主题提供的主题选项" + +#: src/admin/pages/settings-appearance.tsx +msgid "Themes live in the source tree, not the database — they are compiled into the Worker. To switch, edit <0>ACTIVE_THEME in <1>src/themes/index.ts, then build and deploy again." +msgstr "主题位于源代码中,而不在数据库里——它们会被编译进 Worker。要更换主题,请修改 <1>src/themes/index.ts 中的 <0>ACTIVE_THEME,然后重新构建并部署。" + +#: src/admin/pages/settings-site.tsx +msgid "These are stored the moment you save — no rebuild, no deploy." +msgstr "点击保存即生效——无需重新构建或部署。" + +#: src/admin/pages/settings-appearance.tsx +msgid "These values apply to every language unless a language overrides them below." +msgstr "这些值适用于所有语言,除非某个语言在下面单独设置。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Upgrading Mallok itself" +msgstr "升级 Mallok 本身" + +#: src/admin/pages/settings-email.tsx +msgid "Use an address such as hello@example.com or Acme ." +msgstr "请使用 hello@example.com 或 Acme 这样的地址。" + +#: src/admin/pages/settings-appearance.tsx +msgid "Values you change here apply only to {editingLocale}. Anything you leave alone follows the {editingDefaultLocale} value." +msgstr "这里修改的值只对 {editingLocale} 生效。没有改动的选项沿用 {editingDefaultLocale} 的值。" + +#: src/admin/pages/settings-advanced.tsx +msgid "What is instant, and what needs a deploy" +msgstr "哪些立即生效,哪些需要部署" + +#: src/admin/pages/settings-email.tsx +msgid "Without a key no email is sent. A message queued meanwhile is retried for about 30 minutes and then marked failed." +msgstr "没有密钥时不会发送任何邮件。期间排队的邮件会重试约 30 分钟,之后标记为失败。" + +#: src/admin/pages/settings-advanced.tsx +msgid "Work that was retried and gave up — an email that could not be sent, a plugin's job that kept failing. Nothing here is retried again by itself." +msgstr "重试后已放弃的任务——例如发不出去的邮件、反复失败的插件任务。这里的任务不会再自动重试。" diff --git a/src/admin/pages/settings-advanced.tsx b/src/admin/pages/settings-advanced.tsx index fc6db87..d086595 100644 --- a/src/admin/pages/settings-advanced.tsx +++ b/src/admin/pages/settings-advanced.tsx @@ -6,6 +6,9 @@ * and has to be stated once, plainly (docs/ARCHITECTURE.md §15). */ +import { i18n, type MessageDescriptor } from '@lingui/core'; +import { msg, plural } from '@lingui/core/macro'; +import { Trans, useLingui } from '@lingui/react/macro'; import { useQuery, useQueryClient } from '@tanstack/react-query'; import type { JSX, ReactNode } from 'react'; import { useState } from 'react'; @@ -23,7 +26,7 @@ import { StatusBadge, } from '../components/page.js'; import type { ExportProgress } from '../export.js'; -import { formatDateTime } from '../format.js'; +import { formatDateTime, formatNumber } from '../format.js'; import { notify, useReportError } from '../notice.js'; import { healthQuery, keys, saveSettings, useSettings } from '../queries.js'; @@ -43,18 +46,18 @@ interface Diagnostics { /** Exported for `AC-INV-10` (docs/ACCEPTANCE.md §11): the interface's own * words for what is instant and what needs a deploy, asserted directly * rather than re-derived from rendered markup. */ -export const INSTANT = [ - 'Content: create, edit, publish, delete', - 'Site settings, languages, navigation', - 'Theme options this theme declares', - 'Plugin on/off switches, settings and secrets', +export const INSTANT: readonly MessageDescriptor[] = [ + msg`Content: create, edit, publish, delete`, + msg`Site settings, languages, navigation`, + msg`Theme options this theme declares`, + msg`Plugin on/off switches, settings and secrets`, ]; -export const NEEDS_DEPLOY = [ - 'Switching to a different theme', - 'Installing, updating or removing a plugin', - 'Upgrading Mallok itself', - 'Changing anything else in the source tree', +export const NEEDS_DEPLOY: readonly MessageDescriptor[] = [ + msg`Switching to a different theme`, + msg`Installing, updating or removing a plugin`, + msg`Upgrading Mallok itself`, + msg`Changing anything else in the source tree`, ]; /** @@ -69,6 +72,7 @@ function BackupSection(): JSX.Element { const [busy, setBusy] = useState(false); const [progress, setProgress] = useState(null); const [result, setResult] = useState(''); + const { t } = useLingui(); const run = async (): Promise => { setBusy(true); @@ -77,11 +81,14 @@ function BackupSection(): JSX.Element { const { buildExportZip, downloadBlob } = await import('../export.js'); const built = await buildExportZip(setProgress); downloadBlob(built.blob, built.fileName); + const items = built.counts.content; + const files = built.counts.media; + const fileName = built.fileName; setResult( - `${built.counts.content} items and ${built.counts.media} files in ${built.fileName}.`, + t`${plural(items, { one: '# item', other: '# items' })} and ${plural(files, { one: '# file', other: '# files' })} in ${fileName}.`, ); } catch (caught) { - notify(caught instanceof Error ? caught.message : 'The export failed.'); + notify(caught instanceof Error ? caught.message : t`The export failed.`); } finally { setBusy(false); setProgress(null); @@ -90,16 +97,18 @@ function BackupSection(): JSX.Element { return (
    {progress === null ? null : ( - {progress.done}/{progress.total} files + + {progress.done}/{progress.total} files + )} {result === '' ? null : {result}} @@ -109,30 +118,46 @@ function BackupSection(): JSX.Element { ); } -/** Names what asked for a purge, in the operator's terms. */ +/** What asked for a purge, in the operator's terms. */ +const PURGE_SOURCES: Readonly> = { + manual: msg`Clear cached pages`, + content: msg`a content change`, + settings: msg`a settings change`, + plugins: msg`a plugin switch`, + setup: msg`setup`, + scheduled: msg`a scheduled publication`, + fragments: msg`clearing the fragment cache`, +}; + +/** What each storage count is, by the key the Worker reports it under. */ +const STORAGE_COUNTS: Readonly> = { + content: msg`Content items`, + published: msg`Published`, + media: msg`Media files`, + redirects: msg`Redirects`, + fragments: msg`Rendered fragments`, + jobsPending: msg`Background jobs waiting`, +}; + +/** Names what asked for a purge, joined the interface language's way. */ function describePurgeSource(source: string): string { - const named: Readonly> = { - manual: 'Clear cached pages', - content: 'a content change', - settings: 'a settings change', - plugins: 'a plugin switch', - setup: 'setup', - scheduled: 'a scheduled publication', - fragments: 'clearing the fragment cache', - }; - return source - .split(',') - .map((part) => - part.startsWith('plugin:') - ? `the ${part.slice('plugin:'.length)} plugin` - : (named[part] ?? part), - ) - .join(' and '); + const parts = source.split(',').map((part) => { + if (part.startsWith('plugin:')) { + const plugin = part.slice('plugin:'.length); + return i18n._(msg`the ${plugin} plugin`); + } + const named = PURGE_SOURCES[part]; + return named === undefined ? part : i18n._(named); + }); + return new Intl.ListFormat(i18n.locale, { type: 'conjunction' }).format( + parts, + ); } export function AdvancedPage(): JSX.Element { const current = useSettings(); const client = useQueryClient(); + const { t } = useLingui(); // Fresh on every visit: this page is where an operator comes to check. const healthNow = useQuery({ ...healthQuery, refetchOnMount: 'always' }); const loadedDiagnostics = useQuery({ @@ -141,7 +166,7 @@ export function AdvancedPage(): JSX.Element { }); useReportError( healthNow.error ?? loadedDiagnostics.error, - 'Could not load diagnostics.', + t`Could not load diagnostics.`, ); const health = healthNow.data ?? null; const diagnostics = loadedDiagnostics.data ?? null; @@ -158,7 +183,7 @@ export function AdvancedPage(): JSX.Element { await saveSettings({ cacheTtl: effectiveTtl }); setTtl(null); } catch (caught) { - notify(caught instanceof ApiError ? caught.message : 'Could not save.'); + notify(caught instanceof ApiError ? caught.message : t`Could not save.`); } finally { setBusy(false); } @@ -179,7 +204,7 @@ export function AdvancedPage(): JSX.Element { await client.invalidateQueries({ queryKey: keys.health }); } catch (caught) { notify( - caught instanceof ApiError ? caught.message : 'That did not work.', + caught instanceof ApiError ? caught.message : t`That did not work.`, ); } finally { setClearing(''); @@ -187,38 +212,49 @@ export function AdvancedPage(): JSX.Element { }; const purgeFailure = health?.lastPurgeFailure ?? null; + const failedPurge = (() => { + if (purgeFailure === null) { + return ''; + } + const when = formatDateTime(purgeFailure.at); + const cause = describePurgeSource(purgeFailure.source); + const status = purgeFailure.status; + return status === undefined + ? t`${when} — after ${cause}, Cloudflare could not be reached` + : t`${when} — after ${cause}, Cloudflare answered HTTP ${status}`; + })(); const diagnosticsFacts: [ReactNode, ReactNode][] = [ [ - 'Custom domain', + t`Custom domain`, health?.customDomain === null || health === null ? ( - Not bound + Not bound ) : ( {health.customDomain} ), ], [ - 'Edge cache', + t`Edge cache`, health?.customDomain == null ? ( - Inactive — a workers.dev URL is a preview, not a site + Inactive — a workers.dev URL is a preview, not a site ) : ( - Active + Active ), ], [ - 'Cache purge token', + t`Cache purge token`, health?.purgeConfigured === true ? ( - Configured + Configured ) : ( - Not configured — edits go live after the cache expires + Not configured — edits go live after the cache expires ), ], @@ -226,73 +262,72 @@ export function AdvancedPage(): JSX.Element { ? [] : [ [ - 'Last failed purge', + t`Last failed purge`,
    - - {formatDateTime(purgeFailure.at)} — after{' '} - {describePurgeSource(purgeFailure.source)} - {purgeFailure.status === undefined - ? ', Cloudflare could not be reached' - : `, Cloudflare answered HTTP ${purgeFailure.status}`} - + {failedPurge}

    - Pages it named may still be served from the cache until they - expire. {purgeFailure.advice} {purgeFailure.detail} + + Pages it named may still be served from the cache until they + expire. + {' '} + {purgeFailure.advice} {purgeFailure.detail}

    , ] as [ReactNode, ReactNode], ]), [ - 'Email (Resend)', + t`Email (Resend)`, current.email.resendConfigured !== true ? ( - No key — no email is sent + No key — no email is sent ) : current.email.fromAddress === '' ? ( - Key set, no site sender — only plugins with their own send + + Key set, no site sender — only plugins with their own send + ) : ( - Configured + Configured ), ], [ - 'Media domain', + t`Media domain`, health?.mediaBaseUrl == null ? ( - Served through the Worker + Served through the Worker ) : ( {health.mediaBaseUrl} ), ], - ['Theme', {health?.theme ?? '—'}], - ['Render pipeline', {health?.pipeline ?? '—'}], - ['Applied migrations', diagnostics?.migrations.join(', ') ?? '—'], + [t`Theme`, {health?.theme ?? '—'}], + [t`Render pipeline`, {health?.pipeline ?? '—'}], + [t`Applied migrations`, diagnostics?.migrations.join(', ') ?? '—'], ]; return ( -
    +
    {( [ - ['Instant', INSTANT], - ['Needs a rebuild and deploy', NEEDS_DEPLOY], + [t`Instant`, INSTANT], + [t`Needs a rebuild and deploy`, NEEDS_DEPLOY], ] as const ).map(([heading, lines]) => (

    {heading}

      {lines.map((line) => ( -
    • {line}
    • +
    • {i18n._(line)}
    • ))}
    @@ -300,14 +335,14 @@ export function AdvancedPage(): JSX.Element {
    -
    +
    {diagnostics === null || diagnostics.failedJobs.length === 0 ? null : (
      {diagnostics.failedJobs.map((job) => ( @@ -317,7 +352,7 @@ export function AdvancedPage(): JSX.Element { > {job.type} - {job.lastError ?? 'No error was recorded.'} + {job.lastError ?? t`No error was recorded.`} {job.updatedAt.slice(0, 16).replace('T', ' ')} @@ -329,28 +364,35 @@ export function AdvancedPage(): JSX.Element { )}
      {diagnostics === null ? ( -

      Loading…

      +

      + Loading… +

      ) : ( [key, count] as const, - )} + items={Object.entries(diagnostics.counts).map(([key, count]) => { + // A count this admin does not know yet keeps the Worker's key. + const label = STORAGE_COUNTS[key]; + return [ + label === undefined ? key : i18n._(label), + formatNumber(count), + ] as const; + })} /> )}
      -
      +
      - Edge cache lifetime (seconds) + Edge cache lifetime (seconds)
      void saveTtl()} > - {busy ? 'Saving…' : 'Save'} + {busy ? t`Saving…` : t`Save`}
      - Saving content purges the pages it affects, so this is a ceiling for - pages nothing touched — not the delay before an edit appears. + + Saving content purges the pages it affects, so this is a ceiling + for pages nothing touched — not the delay before an edit appears. +
      -

      Clearing caches

      +

      + Clearing caches +

      - Neither of these loses anything. Cached pages and fragments are both - derived from your content and are rebuilt on the next request — the - only cost is that the next visitor waits for a render. + + Neither of these loses anything. Cached pages and fragments are + both derived from your content and are rebuilt on the next request + — the only cost is that the next visitor waits for a render. +

      {cacheResult === '' ? null : ( {cacheResult} diff --git a/src/admin/pages/settings-appearance.tsx b/src/admin/pages/settings-appearance.tsx index 572d326..0059c8a 100644 --- a/src/admin/pages/settings-appearance.tsx +++ b/src/admin/pages/settings-appearance.tsx @@ -7,6 +7,7 @@ * (docs/PRODUCT_VISION.md §4). */ +import { Plural, Trans, useLingui } from '@lingui/react/macro'; import { Info } from 'lucide-react'; import type { JSX } from 'react'; import { useState } from 'react'; @@ -37,6 +38,7 @@ import { saveSettings, useSettings, useTheme } from '../queries.js'; export function AppearancePage(): JSX.Element { const active = useTheme(); const current = useSettings(); + const { t } = useLingui(); const [editingLocale, setEditingLocale] = useState(current.defaultLocale); const [saved, setSaved] = useState(false); @@ -84,18 +86,21 @@ export function AppearancePage(): JSX.Element { setSaved(true); } catch (caught) { showServerErrors(form.setError, caught); - notify(caught instanceof ApiError ? caught.message : 'Could not save.'); + notify(caught instanceof ApiError ? caught.message : t`Could not save.`); } }); const busy = form.formState.isSubmitting; const kinds = Object.entries(active.kinds); + const scripts = active.clientScripts.length; + const builtIn = active.available.join(', '); + const editingDefaultLocale = current.defaultLocale; return (
      kind).join(', ')], + [t`Content types`, kinds.map(([kind]) => kind).join(', ')], [ - 'Client JavaScript', - active.clientScripts.length === 0 ? ( + t`Client JavaScript`, + scripts === 0 ? ( - None + None ) : ( - Injects {active.clientScripts.length} script - {active.clientScripts.length === 1 ? '' : 's'} + ), ], - ['Assets', {active.assetBase}], + [t`Assets`, {active.assetBase}], ]} /> {active.clientScripts.length === 0 ? null : ( @@ -151,17 +159,22 @@ export function AppearancePage(): JSX.Element { - Changing the theme takes a deploy + Changing the theme takes a deploy

      - Themes live in the source tree, not the database — they are compiled - into the Worker. To switch, edit ACTIVE_THEME in{' '} - src/themes/index.ts, then build and deploy again. + + Themes live in the source tree, not the database — they are + compiled into the Worker. To switch, edit{' '} + ACTIVE_THEME in src/themes/index.ts, + then build and deploy again. +

      - Built into this deployment: {active.available.join(', ')}. Your - content, its ids and every URL stay exactly as they are. + + Built into this deployment: {builtIn}. Your content, its ids and + every URL stay exactly as they are. +

      @@ -169,12 +182,12 @@ export function AppearancePage(): JSX.Element { {specs.length === 0 ? null : (
      void submit(event)} footer={ <> {saved ? : null} @@ -182,7 +195,9 @@ export function AppearancePage(): JSX.Element { > {current.locales.length > 1 ? ( - Editing + + Editing + {current.locales.map((locale) => ( - {locale} - {locale === current.defaultLocale ? ' (default)' : ''} + {locale === current.defaultLocale + ? t`${locale} (default)` + : locale} ))} {editingLocale === current.defaultLocale - ? 'These values apply to every language unless a language overrides them below.' - : `Values you change here apply only to ${editingLocale}. Anything you leave alone follows the ${current.defaultLocale} value.`} + ? t`These values apply to every language unless a language overrides them below.` + : t`Values you change here apply only to ${editingLocale}. Anything you leave alone follows the ${editingDefaultLocale} value.`} ) : null} diff --git a/src/admin/pages/settings-email.tsx b/src/admin/pages/settings-email.tsx index bfdb62c..ef46537 100644 --- a/src/admin/pages/settings-email.tsx +++ b/src/admin/pages/settings-email.tsx @@ -8,10 +8,11 @@ */ import { zodResolver } from '@hookform/resolvers/zod'; +import { Trans, useLingui } from '@lingui/react/macro'; import { useQueryClient } from '@tanstack/react-query'; import { TriangleAlert } from 'lucide-react'; import type { JSX } from 'react'; -import { useState } from 'react'; +import { useMemo, useState } from 'react'; import { useForm } from 'react-hook-form'; import { z } from 'zod'; import { Alert, AlertDescription } from '@/components/ui/alert'; @@ -34,21 +35,29 @@ import type { SiteEmail } from '../types.js'; const SENDER_PATTERN = /^(?:[^\s@<>]+@[^\s@<>]+|[^<>]*<[^\s@<>]+@[^\s@<>]+>)$/; /** Empty clears the sender; anything else has to be an address. */ -const senderSchema = z.object({ - from: z - .string() - .trim() - .refine( - (value) => value === '' || SENDER_PATTERN.test(value), - 'Use an address such as hello@example.com or Acme .', - ), -}); +function senderSchema(message: string) { + return z.object({ + from: z + .string() + .trim() + .refine((value) => value === '' || SENDER_PATTERN.test(value), message), + }); +} export function EmailSettingsPage(): JSX.Element { const current = useSettings(); const client = useQueryClient(); + const { t } = useLingui(); + // Built in the interface language, so its message is too. + const schema = useMemo( + () => + senderSchema( + t`Use an address such as hello@example.com or Acme .`, + ), + [t], + ); const form = useForm({ - resolver: zodResolver(senderSchema), + resolver: zodResolver(schema), defaultValues: { from: current.email.fromAddress ?? '' }, }); const fromError = form.formState.errors.from?.message; @@ -74,7 +83,7 @@ export function EmailSettingsPage(): JSX.Element { client.setQueryData(keys.settings, { ...current, email: stored }); return true; } catch (caught) { - notify(caught instanceof ApiError ? caught.message : 'Could not save.'); + notify(caught instanceof ApiError ? caught.message : t`Could not save.`); return false; } }; @@ -102,7 +111,7 @@ export function EmailSettingsPage(): JSX.Element { setVerdict({ ok: false, message: - caught instanceof ApiError ? caught.message : 'The check failed.', + caught instanceof ApiError ? caught.message : t`The check failed.`, }); } finally { setChecking(false); @@ -112,25 +121,31 @@ export function EmailSettingsPage(): JSX.Element { return (
      void saveSender(event)} footer={ <> - {saved ? Saved : null} + {saved ? ( + + Saved + + ) : null} } > - From address + + From address + setSaved(false) })} /> - Must be on a domain you have verified in Resend. A plugin may set - its own sender; this one is used whenever it does not. + + Must be on a domain you have verified in Resend. A plugin may set + its own sender; this one is used whenever it does not. + {fromError}
      - Resend API key + + Resend API key +
      void writeKey(value)} onClear={() => void writeKey(null)} @@ -173,7 +192,7 @@ export function EmailSettingsPage(): JSX.Element { disabled={checking} onClick={() => void check()} > - {checking ? 'Checking…' : 'Test'} + {checking ? t`Checking…` : t`Test`} ) : null} {verdict === null ? null : ( @@ -187,8 +206,10 @@ export function EmailSettingsPage(): JSX.Element { - Without a key no email is sent. A message queued meanwhile is - retried for about 30 minutes and then marked failed. + + Without a key no email is sent. A message queued meanwhile is + retried for about 30 minutes and then marked failed. + )} diff --git a/src/admin/pages/settings-site.tsx b/src/admin/pages/settings-site.tsx index e39c757..fd16fc0 100644 --- a/src/admin/pages/settings-site.tsx +++ b/src/admin/pages/settings-site.tsx @@ -5,6 +5,8 @@ * deploy involved (docs/PRODUCT_VISION.md §5.1). */ +import { plural } from '@lingui/core/macro'; +import { Trans, useLingui } from '@lingui/react/macro'; import type { JSX } from 'react'; import { useState } from 'react'; import { type FieldValues, useForm } from 'react-hook-form'; @@ -26,42 +28,46 @@ import type { FieldSpec } from '../form/types.js'; import { notify } from '../notice.js'; import { reloadWorkspace, saveSettings, useSettings } from '../queries.js'; -const SITE_FIELDS: readonly FieldSpec[] = [ - { - name: 'name', - field: { type: 'string', label: 'Site name', required: true, max: 120 }, - }, - { - name: 'tagline', - field: { - type: 'text', - label: 'Tagline', - required: false, - max: 300, - help: 'Shown by most themes under the site name, and as the home page description.', +/** The site's own fields, labelled in the interface language. */ +function useSiteFields(): readonly FieldSpec[] { + const { t } = useLingui(); + return [ + { + name: 'name', + field: { type: 'string', label: t`Site name`, required: true, max: 120 }, }, - }, - { - name: 'domain', - field: { - type: 'string', - label: 'Custom domain', - required: false, - max: 253, - help: 'Only this host is indexable. Without one, every page is served noindex and the edge cache does not apply.', + { + name: 'tagline', + field: { + type: 'text', + label: t`Tagline`, + required: false, + max: 300, + help: t`Shown by most themes under the site name, and as the home page description.`, + }, }, - }, - { - name: 'mediaBaseUrl', - field: { - type: 'string', - label: 'Media domain', - required: false, - max: 512, - help: 'An R2 custom domain, e.g. https://media.example.com. Empty serves images through the Worker.', + { + name: 'domain', + field: { + type: 'string', + label: t`Custom domain`, + required: false, + max: 253, + help: t`Only this host is indexable. Without one, every page is served noindex and the edge cache does not apply.`, + }, }, - }, -]; + { + name: 'mediaBaseUrl', + field: { + type: 'string', + label: t`Media domain`, + required: false, + max: 512, + help: t`An R2 custom domain, e.g. https://media.example.com. Empty serves images through the Worker.`, + }, + }, + ]; +} /** The form field holding one language's own tagline. */ function taglineField(locale: string): string { @@ -70,6 +76,8 @@ function taglineField(locale: string): string { export function SiteSettingsPage(): JSX.Element { const current = useSettings(); + const { t } = useLingui(); + const siteFields = useSiteFields(); /** The languages that can have a tagline of their own. */ const otherLocales = (current.locales ?? []).filter( (locale) => locale !== current.defaultLocale, @@ -98,7 +106,7 @@ export function SiteSettingsPage(): JSX.Element { const [saved, setSaved] = useState(false); // A tagline field per further language, right under the tagline itself. - const fields: readonly FieldSpec[] = SITE_FIELDS.flatMap((spec) => + const fields: readonly FieldSpec[] = siteFields.flatMap((spec) => spec.name === 'tagline' ? [ spec, @@ -107,10 +115,10 @@ export function SiteSettingsPage(): JSX.Element { name: taglineField(locale), field: { type: 'text', - label: `Tagline (${locale})`, + label: t`Tagline (${locale})`, required: false, max: 300, - help: `Shown on pages in ${locale}. Empty uses the tagline above.`, + help: t`Shown on pages in ${locale}. Empty uses the tagline above.`, }, }), ), @@ -147,7 +155,7 @@ export function SiteSettingsPage(): JSX.Element { setSaved(true); } catch (caught) { showServerErrors(form.setError, caught); - notify(caught instanceof ApiError ? caught.message : 'Could not save.'); + notify(caught instanceof ApiError ? caught.message : t`Could not save.`); } }); const busy = form.formState.isSubmitting; @@ -155,8 +163,8 @@ export function SiteSettingsPage(): JSX.Element { return (
      {saved ? : null} @@ -188,15 +196,17 @@ export function SiteSettingsPage(): JSX.Element { */ function LocaleSection(): JSX.Element { const current = useSettings(); + const { t } = useLingui(); const [busy, setBusy] = useState(false); const [adding, setAdding] = useState(''); + const prefix = current.defaultLocale; const setLocales = async (locales: string[]): Promise => { setBusy(true); try { await saveSettings({ locales }); } catch (caught) { - notify(caught instanceof ApiError ? caught.message : 'Could not save.'); + notify(caught instanceof ApiError ? caught.message : t`Could not save.`); } finally { setBusy(false); } @@ -204,7 +214,7 @@ function LocaleSection(): JSX.Element { const makeDefault = async (locale: string): Promise => { const ok = window.confirm( - `Make "${locale}" the default language?\n\nEvery public URL is rewritten and the old URLs are redirected. This cannot be undone automatically.`, + t`Make "${locale}" the default language?\n\nEvery public URL is rewritten and the old URLs are redirected. This cannot be undone automatically.`, ); if (!ok) { return; @@ -216,11 +226,14 @@ function LocaleSection(): JSX.Element { body: { locale, confirm: true }, }); await reloadWorkspace(); + const moved = result.moved; notify( - `Default language is now "${locale}". ${result.moved} URLs moved, each with a redirect.`, + t`Default language is now "${locale}". ${plural(moved, { one: '# URL moved, with a redirect.', other: '# URLs moved, each with a redirect.' })}`, ); } catch (caught) { - notify(caught instanceof ApiError ? caught.message : 'Could not switch.'); + notify( + caught instanceof ApiError ? caught.message : t`Could not switch.`, + ); } finally { setBusy(false); } @@ -229,8 +242,8 @@ function LocaleSection(): JSX.Element { const setPrefix = async (enabled: boolean): Promise => { const ok = window.confirm( enabled - ? `Serve "${current.defaultLocale}" under /${current.defaultLocale}/ too?\n\nEvery URL of the default language moves (/about becomes /${current.defaultLocale}/about) and each old URL, lists and tags included, redirects to its new one. The navigation's links to this site are rewritten to match. The site's root then only redirects to /${current.defaultLocale}.` - : `Serve "${current.defaultLocale}" at the root again?\n\nEvery URL of the default language moves (/${current.defaultLocale}/about becomes /about) and each old URL, lists, tags and /${current.defaultLocale} included, redirects to its new one. The navigation's links to this site are rewritten to match.`, + ? t`Serve "${prefix}" under /${prefix}/ too?\n\nEvery URL of the default language moves (/about becomes /${prefix}/about) and each old URL, lists and tags included, redirects to its new one. The navigation's links to this site are rewritten to match. The site's root then only redirects to /${prefix}.` + : t`Serve "${prefix}" at the root again?\n\nEvery URL of the default language moves (/${prefix}/about becomes /about) and each old URL, lists, tags and /${prefix} included, redirects to its new one. The navigation's links to this site are rewritten to match.`, ); if (!ok) { return; @@ -242,11 +255,18 @@ function LocaleSection(): JSX.Element { body: { enabled, confirm: true }, }); await reloadWorkspace(); + const moved = result.moved; notify( - `${result.moved} URLs moved, each with a redirect; navigation links rewritten.`, + plural(moved, { + one: '# URL moved, with a redirect; navigation links rewritten.', + other: + '# URLs moved, each with a redirect; navigation links rewritten.', + }), ); } catch (caught) { - notify(caught instanceof ApiError ? caught.message : 'Could not switch.'); + notify( + caught instanceof ApiError ? caught.message : t`Could not switch.`, + ); } finally { setBusy(false); } @@ -254,19 +274,19 @@ function LocaleSection(): JSX.Element { return (
      + Every language is served under /<locale>/, the default one too; the site's root redirects to{' '} - /{current.defaultLocale}. - + /{prefix}. + ) : ( - <> + The default language has no URL prefix; every other language is served under /<locale>/. - + ) } > @@ -280,8 +300,9 @@ function LocaleSection(): JSX.Element { {/* One run of text: the label lays its children out with a gap. */} - Prefix the default language too ( - /{current.defaultLocale}/…) + + Prefix the default language too (/{prefix}/…) + @@ -293,7 +314,9 @@ function LocaleSection(): JSX.Element { > {locale} {locale === current.defaultLocale ? ( - Default + + Default + ) : (
      )} @@ -326,7 +349,7 @@ function LocaleSection(): JSX.Element {
      setAdding(event.currentTarget.value)} @@ -340,7 +363,7 @@ function LocaleSection(): JSX.Element { setAdding(''); }} > - Add language + Add language
      diff --git a/test/admin/redeploy-notice.test.ts b/test/admin/redeploy-notice.test.ts index f942836..3afe26e 100644 --- a/test/admin/redeploy-notice.test.ts +++ b/test/admin/redeploy-notice.test.ts @@ -25,10 +25,15 @@ function flatten(text: string): string { } describe('AC-INV-10: the interface names what needs a deploy', () => { + // The lists are messages now (docs/ADMIN_I18N_AND_UI.md); their English is + // what the interface says when no other language is chosen. + const instant = INSTANT.map((line) => line.message); + const needsDeploy = NEEDS_DEPLOY.map((line) => line.message); + it('says switching themes and installing plugins are not instant', () => { - expect(INSTANT).not.toContain('Switching to a different theme'); - expect(NEEDS_DEPLOY).toContain('Switching to a different theme'); - expect(NEEDS_DEPLOY).toContain('Installing, updating or removing a plugin'); + expect(instant).not.toContain('Switching to a different theme'); + expect(needsDeploy).toContain('Switching to a different theme'); + expect(needsDeploy).toContain('Installing, updating or removing a plugin'); }); }); diff --git a/vitest.config.ts b/vitest.config.ts index bef8e23..2a2d1d8 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -1,6 +1,7 @@ import { readFile } from 'node:fs/promises'; import { fileURLToPath } from 'node:url'; import { cloudflareTest } from '@cloudflare/vitest-pool-workers'; +import { lingui } from '@lingui/vite-plugin'; import react from '@vitejs/plugin-react'; import { defineConfig, type Plugin } from 'vitest/config'; @@ -125,7 +126,17 @@ export default defineConfig({ }, projects: [ { - plugins: [textModules()], + // test/admin imports the admin's pages, whose messages are Lingui + // macros; they compile here as they do in vite.config.ts. + plugins: [ + textModules(), + lingui({ + macroTransform: true, + configPath: fileURLToPath( + new URL('./lingui.config.ts', import.meta.url), + ), + }), + ], // The admin's own alias (vite.config.ts): its pages import shadcn/ui // as `@/components/ui/…`, and test/admin imports its pages. resolve: { From d2308002ee68ad1c321c0a7fed4057138ccd14e5 Mon Sep 17 00:00:00 2001 From: JasonYv <233965174+JasonYv@users.noreply.github.com> Date: Fri, 13 Nov 2026 18:47:58 -0800 Subject: [PATCH 06/38] feat(admin): translate the account, content list and media pages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The account page, the content list, the media library and its picker, the token status lines and the upload errors now read in Simplified Chinese when that is the interface language. - Token statuses are whole sentences rather than a status joined to a lower-cased "used" phrase, so word order belongs to the translation. - The "in use" refusal counts its references with a real plural. - The upload widths are a conjunction list without digit grouping: Chinese joins a unit list with no separator, which printed "4809601,440". - A status badge wraps only where English would (`break-keep`); in a narrow cell Chinese stacked "已发布" one character per line. Content kind names come from the theme and stay as declared until the theme overlays of phase 3. Co-Authored-By: Claude Opus 5.5 --- src/admin/components/media-library.tsx | 91 ++++++-- src/admin/components/page.tsx | 5 +- src/admin/locales/en.po | 306 +++++++++++++++++++++++++ src/admin/locales/zh-CN.po | 306 +++++++++++++++++++++++++ src/admin/media.ts | 8 +- src/admin/pages/account.tsx | 91 +++++--- src/admin/pages/content-list.tsx | 80 +++++-- src/admin/pages/media.tsx | 6 +- src/admin/tokens.ts | 23 +- test/admin/tokens.test.ts | 7 +- 10 files changed, 825 insertions(+), 98 deletions(-) diff --git a/src/admin/components/media-library.tsx b/src/admin/components/media-library.tsx index af5e4e1..8832b9a 100644 --- a/src/admin/components/media-library.tsx +++ b/src/admin/components/media-library.tsx @@ -6,6 +6,9 @@ * stores URLs cannot be exported and moved (docs/CONTENT_FORMAT.md §4). */ +import { i18n, type MessageDescriptor } from '@lingui/core'; +import { msg, plural } from '@lingui/core/macro'; +import { Trans, useLingui } from '@lingui/react/macro'; import { useQuery, useQueryClient } from '@tanstack/react-query'; import { cn } from 'cn'; import { Upload } from 'lucide-react'; @@ -20,6 +23,7 @@ import { } from '@/components/ui/dialog'; import { Input } from '@/components/ui/input'; import { ApiError, api } from '../api.js'; +import { formatNumber } from '../format.js'; import { relativePathFor, type UploadProgress, uploadFile } from '../media.js'; import { messageOf, notify } from '../notice.js'; import { keys, useSettings, useTheme } from '../queries.js'; @@ -33,7 +37,18 @@ export interface MediaLibraryProps { readonly onClose?: () => void; } +/** What each stage of an upload is called while it runs. */ +const STAGES: Readonly> = { + hashing: msg`hashing`, + checking: msg`checking`, + converting: msg`converting`, + uploading: msg`uploading`, + done: msg`done`, + skipped: msg`already stored, skipped`, +}; + export function MediaLibrary(props: MediaLibraryProps): JSX.Element { + const { t } = useLingui(); const [progress, setProgress] = useState(null); const [error, setError] = useState(''); const [dragging, setDragging] = useState(false); @@ -42,6 +57,16 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { const active = useTheme(); const site = useSettings(); const client = useQueryClient(); + // A conjunction list, not a `unit` one: Chinese joins a unit list with no + // separator at all, so 480, 960 and 1440 read as "4809601440". Pixel widths + // are not grouped, like the numbers in a srcset. + const widths = new Intl.ListFormat(i18n.locale, { + type: 'conjunction', + }).format( + active.imageWidths.map((width) => + formatNumber(width, { useGrouping: false }), + ), + ); const listed = useQuery({ queryKey: [...keys.media, 'list', props.kind ?? 'all'], @@ -55,7 +80,7 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { const loadError = listed.error === null ? '' - : messageOf(listed.error, 'Could not load media.'); + : messageOf(listed.error, t`Could not load media.`); /** The library changed: every list of it, and every item's row. */ const reload = (): Promise => client.invalidateQueries({ queryKey: keys.media }); @@ -74,7 +99,7 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { }); } catch (caught) { setError( - caught instanceof Error ? caught.message : 'The upload failed.', + caught instanceof Error ? caught.message : t`The upload failed.`, ); } } @@ -84,8 +109,12 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { const remove = async (item: MediaItem): Promise => { if (item.refCount > 0) { + const name = item.originalName; notify( - `"${item.originalName}" is used by ${item.refCount} item${item.refCount === 1 ? '' : 's'}. Remove the references first.`, + plural(item.refCount, { + one: `"${name}" is used by # item. Remove the reference first.`, + other: `"${name}" is used by # items. Remove the references first.`, + }), ); return; } @@ -93,7 +122,9 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { await api(`/media/${item.sha256}`, { method: 'DELETE' }); await reload(); } catch (caught) { - notify(caught instanceof ApiError ? caught.message : 'Could not delete.'); + notify( + caught instanceof ApiError ? caught.message : t`Could not delete.`, + ); } }; @@ -106,7 +137,7 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { setEditing(null); await reload(); } catch (caught) { - notify(caught instanceof ApiError ? caught.message : 'Could not save.'); + notify(caught instanceof ApiError ? caught.message : t`Could not save.`); } }; @@ -148,17 +179,22 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { }} /> - {dragging ? 'Drop to upload' : 'Choose files, or drop them here'} + {dragging ? ( + Drop to upload + ) : ( + Choose files, or drop them here + )}

      - Images are converted to WebP in your browser and uploaded at{' '} - {active.imageWidths.join(', ')} pixels wide. SVG is not accepted — it - can carry script. + + Images are converted to WebP in your browser and uploaded at{' '} + {widths} pixels wide. SVG is not accepted — it can carry script. +

      {progress === null ? null : (

      - {progress.file}: {progress.stage} + {progress.file}: {i18n._(STAGES[progress.stage])}

      )} {error === '' && loadError === '' ? null : ( @@ -169,10 +205,12 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element {
      {loading ? ( -

      Loading…

      +

      + Loading… +

      ) : items.length === 0 ? (

      - No media yet. + No media yet.

      ) : (
        @@ -204,16 +242,15 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { {item.width === null ? `${Math.round(item.bytes / 1024)} KB` : `${item.width}×${item.height}`} - {item.refCount === 0 - ? ' · unused' - : ` · used ${item.refCount}×`} + {' · '} + {item.refCount === 0 ? t`unused` : t`used ${item.refCount}×`} {item.kind !== 'image' ? null : editing === item.sha256 ? (
        setAltDraft(event.currentTarget.value) @@ -225,7 +262,7 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { size="sm" onClick={() => void saveAlt(item)} > - Save + Save
        ) : ( @@ -240,8 +277,8 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { }} > {item.alt === null || item.alt === '' - ? 'Add alt text' - : `Alt: ${item.alt}`} + ? t`Add alt text` + : t`Alt: ${item.alt}`} )}
      @@ -252,7 +289,7 @@ export function MediaLibrary(props: MediaLibraryProps): JSX.Element { size="sm" onClick={() => props.onPick?.(relativePathFor(item), item)} > - Use + Use )}
      @@ -306,7 +343,11 @@ export function MediaPicker(props: { > - Choose {props.kind === 'image' ? 'an image' : 'a file'} + {props.kind === 'image' ? ( + Choose an image + ) : ( + Choose a file + )} CF_API_TOKEN and <1>CF_ZONE_ID as Worker secrets to get instant publishing." msgstr "No cache-purge token is configured, so a saved change reaches visitors only after the cached page expires. This is a working site, not a broken one — add <0>CF_API_TOKEN and <1>CF_ZONE_ID as Worker secrets to get instant publishing." @@ -373,6 +566,10 @@ msgstr "No error was recorded." msgid "No key — no email is sent" msgstr "No key — no email is sent" +#: src/admin/components/media-library.tsx +msgid "No media yet." +msgstr "No media yet." + #: src/admin/pages/settings-appearance.tsx msgid "None" msgstr "None" @@ -389,6 +586,14 @@ msgstr "Not configured — edits go live after the cache expires" msgid "Not found" msgstr "Not found" +#: src/admin/pages/content-list.tsx +msgid "Not in theme" +msgstr "Not in theme" + +#: src/admin/pages/content-list.tsx +msgid "Nothing here yet." +msgstr "Nothing here yet." + #: src/admin/pages/settings-email.tsx msgid "One Resend key and one sender address for the whole site. Every plugin that sends email uses them, and a change applies to the next message — no rebuild, no deploy." msgstr "One Resend key and one sender address for the whole site. Every plugin that sends email uses them, and a change applies to the next message — no rebuild, no deploy." @@ -401,10 +606,23 @@ msgstr "Only this host is indexable. Without one, every page is served noindex a msgid "Pages it named may still be served from the cache until they expire." msgstr "Pages it named may still be served from the cache until they expire." +#: src/admin/pages/content-list.tsx +msgid "Pagination" +msgstr "Pagination" + +#: src/admin/pages/account.tsx #: src/admin/pages/login.tsx msgid "Password" msgstr "Password" +#: src/admin/pages/account.tsx +msgid "Passwords are hashed with PBKDF2-SHA256 at {iterations} iterations. Current guidance is {recommended}, but a sign-in has to finish inside the Cloudflare Free plan's 10 ms CPU budget, so the cost is capped." +msgstr "Passwords are hashed with PBKDF2-SHA256 at {iterations} iterations. Current guidance is {recommended}, but a sign-in has to finish inside the Cloudflare Free plan's 10 ms CPU budget, so the cost is capped." + +#: src/admin/pages/content-list.tsx +msgid "Path" +msgstr "Path" + #: src/admin/pages/settings-advanced.tsx msgid "Plugin on/off switches, settings and secrets" msgstr "Plugin on/off switches, settings and secrets" @@ -417,6 +635,11 @@ msgstr "Plugins" msgid "Prefix the default language too (<0>/{prefix}/…)" msgstr "Prefix the default language too (<0>/{prefix}/…)" +#: src/admin/pages/content-list.tsx +msgid "Previous" +msgstr "Previous" + +#: src/admin/pages/content-list.tsx #: src/admin/pages/settings-advanced.tsx msgid "Published" msgstr "Published" @@ -445,10 +668,23 @@ msgstr "Rendered fragments" msgid "Resend API key" msgstr "Resend API key" +#: src/admin/pages/account.tsx +msgid "Revoke" +msgstr "Revoke" + +#: src/admin/tokens.ts +msgid "Revoked {revoked} · last used {lastUsed}" +msgstr "Revoked {revoked} · last used {lastUsed}" + +#: src/admin/tokens.ts +msgid "Revoked {revoked} · never used" +msgstr "Revoked {revoked} · never used" + #: src/admin/components/account-menu.tsx msgid "Same as the system" msgstr "Same as the system" +#: src/admin/components/media-library.tsx #: src/admin/pages/settings-advanced.tsx #: src/admin/pages/settings-site.tsx msgid "Save" @@ -485,6 +721,14 @@ msgstr "Saving content purges the pages it affects, so this is a ceiling for pag msgid "Saving…" msgstr "Saving…" +#: src/admin/pages/content-list.tsx +msgid "Scheduled" +msgstr "Scheduled" + +#: src/admin/pages/account.tsx +msgid "Scopes" +msgstr "Scopes" + #: src/admin/pages/settings-email.tsx msgid "Sender" msgstr "Sender" @@ -554,6 +798,10 @@ msgstr "Site name" msgid "Site settings, languages, navigation" msgstr "Site settings, languages, navigation" +#: src/admin/pages/content-list.tsx +msgid "Status" +msgstr "Status" + #: src/admin/pages/settings-advanced.tsx msgid "Storage" msgstr "Storage" @@ -562,6 +810,10 @@ msgstr "Storage" msgid "Stored encrypted. It is never shown again, here or anywhere else." msgstr "Stored encrypted. It is never shown again, here or anywhere else." +#: src/admin/media.ts +msgid "SVG is not accepted: it can carry script. Export a PNG or WebP instead." +msgstr "SVG is not accepted: it can carry script. Export a PNG or WebP instead." + #: src/admin/pages/settings-advanced.tsx msgid "Switching to a different theme" msgstr "Switching to a different theme" @@ -582,14 +834,26 @@ msgstr "Test" msgid "That did not work." msgstr "That did not work." +#: src/admin/tokens.ts +msgid "That token was already revoked." +msgstr "That token was already revoked." + #: src/admin/pages/settings-advanced.tsx msgid "the {plugin} plugin" msgstr "the {plugin} plugin" +#: src/admin/pages/content-list.tsx +msgid "The active theme does not declare this type, so it renders with the page layout. The content and its URL are untouched." +msgstr "The active theme does not declare this type, so it renders with the page layout. The content and its URL are untouched." + #: src/admin/pages/settings-email.tsx msgid "The check failed." msgstr "The check failed." +#: src/admin/pages/account.tsx +msgid "The CLI and any script use these. A token is shown once — copy it now, it cannot be retrieved later." +msgstr "The CLI and any script use these. A token is shown once — copy it now, it cannot be retrieved later." + #: src/admin/pages/settings-site.tsx msgid "The default language has no URL prefix; every other language is served under <0>//." msgstr "The default language has no URL prefix; every other language is served under <0>//." @@ -606,6 +870,11 @@ msgstr "The options below are runtime settings: saving takes effect without a re msgid "The site's admin" msgstr "The site's admin" +#: src/admin/components/media-library.tsx +#: src/admin/media.ts +msgid "The upload failed." +msgstr "The upload failed." + #: src/admin/pages/settings-advanced.tsx msgid "Theme" msgstr "Theme" @@ -630,14 +899,51 @@ msgstr "These are stored the moment you save — no rebuild, no deploy." msgid "These values apply to every language unless a language overrides them below." msgstr "These values apply to every language unless a language overrides them below." +#: src/admin/pages/content-list.tsx +msgid "Title" +msgstr "Title" + +#: src/admin/pages/content-list.tsx +msgid "Type" +msgstr "Type" + +#: src/admin/media.ts +msgid "unknown type" +msgstr "unknown type" + +#: src/admin/components/media-library.tsx +msgid "unused" +msgstr "unused" + +#: src/admin/pages/content-list.tsx +msgid "Updated" +msgstr "Updated" + #: src/admin/pages/settings-advanced.tsx msgid "Upgrading Mallok itself" msgstr "Upgrading Mallok itself" +#: src/admin/components/media-library.tsx +msgid "uploading" +msgstr "uploading" + +#: src/admin/components/media-library.tsx +msgid "Use" +msgstr "Use" + +#: src/admin/pages/account.tsx +msgid "Use a long, unique password. For stronger protection, put Cloudflare Access in front of <0>/_mallok/." +msgstr "Use a long, unique password. For stronger protection, put Cloudflare Access in front of <0>/_mallok/." + #: src/admin/pages/settings-email.tsx msgid "Use an address such as hello@example.com or Acme ." msgstr "Use an address such as hello@example.com or Acme ." +#. placeholder {0}: item.refCount +#: src/admin/components/media-library.tsx +msgid "used {0}×" +msgstr "used {0}×" + #: src/admin/pages/settings-appearance.tsx msgid "Values you change here apply only to {editingLocale}. Anything you leave alone follows the {editingDefaultLocale} value." msgstr "Values you change here apply only to {editingLocale}. Anything you leave alone follows the {editingDefaultLocale} value." diff --git a/src/admin/locales/zh-CN.po b/src/admin/locales/zh-CN.po index 786ec4b..f8de46a 100644 --- a/src/admin/locales/zh-CN.po +++ b/src/admin/locales/zh-CN.po @@ -7,6 +7,15 @@ msgstr "" "X-Generator: @lingui/cli\n" "Language: zh-CN\n" +#: src/admin/media.ts +msgid "\"{type}\" is not accepted." +msgstr "不支持“{type}”类型的文件。" + +#. placeholder {0}: item.refCount +#: src/admin/components/media-library.tsx +msgid "{0, plural, one {\"{name}\" is used by # item. Remove the reference first.} other {\"{name}\" is used by # items. Remove the references first.}}" +msgstr "{0, plural, other {“{name}”正被 # 项内容引用,请先移除引用。}}" + #. placeholder {0}: progress.done #. placeholder {1}: progress.total #: src/admin/pages/settings-advanced.tsx @@ -57,8 +66,13 @@ msgstr "设置修改" msgid "A zip containing every page as Markdown, its images, your settings and your inquiries. It is a complete site you can read anywhere — take it to Astro, Hugo or Obsidian whenever you like. Export before upgrading." msgstr "一个 zip 压缩包,包含所有页面的 Markdown、图片、站点设置和询盘。它是一个完整的站点,在哪里都能读取——随时可以带去 Astro、Hugo 或 Obsidian。升级前请先导出。" +#: src/admin/pages/account.tsx +msgid "About password hashing" +msgstr "关于密码哈希" + #: src/admin/components/account-menu.tsx #: src/admin/components/shell.tsx +#: src/admin/pages/account.tsx msgid "Account" msgstr "账号" @@ -75,6 +89,10 @@ msgstr "账号菜单" msgid "Active" msgstr "已生效" +#: src/admin/components/media-library.tsx +msgid "Add alt text" +msgstr "添加替代文本" + #: src/admin/pages/settings-site.tsx msgid "Add language" msgstr "添加语言" @@ -84,10 +102,31 @@ msgstr "添加语言" msgid "Advanced" msgstr "高级" +#: src/admin/pages/content-list.tsx +msgid "All" +msgstr "全部" + +#: src/admin/components/media-library.tsx +msgid "already stored, skipped" +msgstr "已存在,已跳过" + +#: src/admin/components/media-library.tsx +msgid "Alt text" +msgstr "替代文本" + +#. placeholder {0}: item.alt +#: src/admin/components/media-library.tsx +msgid "Alt: {0}" +msgstr "替代文本:{0}" + #: src/admin/pages/settings-site.tsx msgid "An R2 custom domain, e.g. https://media.example.com. Empty serves images through the Worker." msgstr "R2 的自定义域名,例如 https://media.example.com。留空则由 Worker 提供图片。" +#: src/admin/pages/account.tsx +msgid "API tokens" +msgstr "API 令牌" + #: src/admin/components/shell.tsx #: src/admin/pages/settings-appearance.tsx msgid "Appearance" @@ -101,6 +140,10 @@ msgstr "已执行的迁移" msgid "Assets" msgstr "静态资源" +#: src/admin/pages/account.tsx +msgid "At least 12 characters." +msgstr "至少 12 个字符。" + #: src/admin/pages/settings-advanced.tsx msgid "Background jobs waiting" msgstr "等待中的后台任务" @@ -125,6 +168,14 @@ msgstr "缓存" msgid "Cache purge token" msgstr "缓存清除令牌" +#: src/admin/pages/account.tsx +msgid "Change password" +msgstr "修改密码" + +#: src/admin/pages/account.tsx +msgid "Changed" +msgstr "已修改" + #: src/admin/components/saved-note.tsx msgid "Changes reach visitors within {within}" msgstr "修改将在 {within}内对访客可见" @@ -137,10 +188,30 @@ msgstr "修改源代码中的其他任何内容" msgid "Changing the theme takes a deploy" msgstr "更换主题需要重新部署" +#: src/admin/pages/account.tsx +msgid "Changing…" +msgstr "正在修改…" + +#: src/admin/components/media-library.tsx +msgid "checking" +msgstr "正在检查" + #: src/admin/pages/settings-email.tsx msgid "Checking…" msgstr "正在检测…" +#: src/admin/components/media-library.tsx +msgid "Choose a file" +msgstr "选择文件" + +#: src/admin/components/media-library.tsx +msgid "Choose an image" +msgstr "选择图片" + +#: src/admin/components/media-library.tsx +msgid "Choose files, or drop them here" +msgstr "选择文件,或拖放到这里" + #: src/admin/pages/settings-advanced.tsx msgid "Clear cached pages" msgstr "清除页面缓存" @@ -182,6 +253,7 @@ msgid "Configured" msgstr "已配置" #: src/admin/components/shell.tsx +#: src/admin/pages/content-list.tsx msgid "Content" msgstr "内容" @@ -197,10 +269,47 @@ msgstr "内容类型" msgid "Content: create, edit, publish, delete" msgstr "内容:新建、编辑、发布、删除" +#: src/admin/components/media-library.tsx +msgid "converting" +msgstr "正在转换" + +#: src/admin/pages/account.tsx +msgid "Copy" +msgstr "复制" + +#: src/admin/pages/account.tsx +msgid "Could not change the password." +msgstr "密码修改失败。" + +#: src/admin/pages/account.tsx +msgid "Could not create." +msgstr "创建失败。" + +#: src/admin/components/media-library.tsx +msgid "Could not delete." +msgstr "删除失败。" + +#: src/admin/pages/content-list.tsx +msgid "Could not load content." +msgstr "无法加载内容。" + #: src/admin/pages/settings-advanced.tsx msgid "Could not load diagnostics." msgstr "无法加载诊断信息。" +#: src/admin/components/media-library.tsx +msgid "Could not load media." +msgstr "无法加载媒体。" + +#: src/admin/pages/account.tsx +msgid "Could not load tokens." +msgstr "无法加载令牌。" + +#: src/admin/tokens.ts +msgid "Could not revoke the token." +msgstr "无法撤销令牌。" + +#: src/admin/components/media-library.tsx #: src/admin/pages/settings-advanced.tsx #: src/admin/pages/settings-appearance.tsx #: src/admin/pages/settings-email.tsx @@ -212,6 +321,14 @@ msgstr "保存失败。" msgid "Could not switch." msgstr "切换失败。" +#: src/admin/pages/account.tsx +msgid "Create token" +msgstr "创建令牌" + +#: src/admin/pages/account.tsx +msgid "Current password" +msgstr "当前密码" + #: src/admin/pages/settings-advanced.tsx #: src/admin/pages/settings-site.tsx msgid "Custom domain" @@ -229,10 +346,38 @@ msgstr "默认" msgid "Default language is now \"{locale}\". {moved, plural, one {# URL moved, with a redirect.} other {# URLs moved, each with a redirect.}}" msgstr "默认语言已改为“{locale}”。{moved, plural, other {已迁移 # 个 URL,均已设置重定向。}}" +#: src/admin/components/media-library.tsx +msgid "Delete" +msgstr "删除" + +#: src/admin/components/media-library.tsx +msgid "Delete permanently" +msgstr "永久删除" + +#: src/admin/components/media-library.tsx +msgid "Describe the image" +msgstr "描述这张图片" + #: src/admin/pages/settings-advanced.tsx msgid "Diagnostics" msgstr "诊断" +#: src/admin/components/media-library.tsx +msgid "done" +msgstr "完成" + +#: src/admin/pages/account.tsx +msgid "Done" +msgstr "完成" + +#: src/admin/pages/content-list.tsx +msgid "Draft" +msgstr "草稿" + +#: src/admin/components/media-library.tsx +msgid "Drop to upload" +msgstr "松开即可上传" + #: src/admin/pages/settings-advanced.tsx msgid "Edge cache" msgstr "边缘缓存" @@ -275,10 +420,26 @@ msgstr "全部导出" msgid "Failed background jobs" msgstr "失败的后台任务" +#: src/admin/pages/media.tsx +msgid "Files are stored by the hash of the original, so uploading the same image twice costs nothing and never creates a duplicate." +msgstr "文件按原图的哈希值存储,同一张图片上传两次不会产生额外开销,也不会出现重复。" + #: src/admin/pages/settings-email.tsx msgid "From address" msgstr "发件地址" +#: src/admin/components/media-library.tsx +msgid "hashing" +msgstr "正在计算哈希" + +#: src/admin/components/media-library.tsx +msgid "Images are converted to WebP in your browser and uploaded at {widths} pixels wide. SVG is not accepted — it can carry script." +msgstr "图片会在浏览器中转换为 WebP,并按 {widths} 像素宽度上传。不支持 SVG——它可能携带脚本。" + +#: src/admin/components/media-library.tsx +msgid "In use. Remove the references first." +msgstr "正在使用中,请先移除引用。" + #: src/admin/pages/settings-advanced.tsx msgid "Inactive — a workers.dev URL is a preview, not a site" msgstr "未生效 — workers.dev 地址只是预览,不是正式站点" @@ -300,6 +461,10 @@ msgstr "界面语言" msgid "Key set, no site sender — only plugins with their own send" msgstr "已设置密钥,但没有站点发件地址 — 只有自带发件地址的插件能发送" +#: src/admin/pages/content-list.tsx +msgid "Language" +msgstr "语言" + #: src/admin/pages/settings-site.tsx msgid "Language code" msgstr "语言代码" @@ -312,10 +477,16 @@ msgstr "语言" msgid "Last failed purge" msgstr "最近一次清除失败" +#: src/admin/tokens.ts +msgid "Last used {lastUsed}" +msgstr "最近使用于 {lastUsed}" + #: src/admin/components/account-menu.tsx msgid "Light" msgstr "浅色" +#: src/admin/components/media-library.tsx +#: src/admin/pages/content-list.tsx #: src/admin/pages/settings-advanced.tsx msgid "Loading…" msgstr "正在加载…" @@ -333,6 +504,8 @@ msgid "Make default" msgstr "设为默认" #: src/admin/components/shell.tsx +#: src/admin/pages/content-list.tsx +#: src/admin/pages/media.tsx msgid "Media" msgstr "媒体" @@ -357,10 +530,30 @@ msgstr "需要重新构建并部署" msgid "Neither of these loses anything. Cached pages and fragments are both derived from your content and are rebuilt on the next request — the only cost is that the next visitor waits for a render." msgstr "两者都不会丢失任何数据。页面缓存和片段缓存都由内容生成,下一次请求时会重新生成——唯一的代价是下一位访客需要等待一次渲染。" +#: src/admin/tokens.ts +msgid "Never used" +msgstr "从未使用" + +#: src/admin/pages/content-list.tsx +msgid "New" +msgstr "新建" + #: src/admin/components/shell.tsx msgid "New item" msgstr "新建" +#: src/admin/pages/account.tsx +msgid "New password" +msgstr "新密码" + +#: src/admin/pages/account.tsx +msgid "New token name" +msgstr "新令牌名称" + +#: src/admin/pages/content-list.tsx +msgid "Next" +msgstr "下一页" + #: src/admin/components/saved-note.tsx msgid "No cache-purge token is configured, so a saved change reaches visitors only after the cached page expires. This is a working site, not a broken one — add <0>CF_API_TOKEN and <1>CF_ZONE_ID as Worker secrets to get instant publishing." msgstr "尚未配置缓存清除令牌,保存的修改要等页面缓存过期后访客才能看到。站点运行正常,并没有出错——将 <0>CF_API_TOKEN 和 <1>CF_ZONE_ID 添加为 Worker 密钥即可即时发布。" @@ -373,6 +566,10 @@ msgstr "没有记录到错误信息。" msgid "No key — no email is sent" msgstr "未设置密钥 — 不会发送任何邮件" +#: src/admin/components/media-library.tsx +msgid "No media yet." +msgstr "还没有媒体文件。" + #: src/admin/pages/settings-appearance.tsx msgid "None" msgstr "无" @@ -389,6 +586,14 @@ msgstr "未配置 — 修改要等缓存过期后才生效" msgid "Not found" msgstr "未找到" +#: src/admin/pages/content-list.tsx +msgid "Not in theme" +msgstr "主题未声明" + +#: src/admin/pages/content-list.tsx +msgid "Nothing here yet." +msgstr "这里还没有内容。" + #: src/admin/pages/settings-email.tsx msgid "One Resend key and one sender address for the whole site. Every plugin that sends email uses them, and a change applies to the next message — no rebuild, no deploy." msgstr "整个站点共用一个 Resend 密钥和一个发件地址。所有发送邮件的插件都使用它们,修改后对下一封邮件生效——无需重新构建或部署。" @@ -401,10 +606,23 @@ msgstr "只有这个域名会被搜索引擎收录。未设置时,所有页面 msgid "Pages it named may still be served from the cache until they expire." msgstr "涉及的页面在缓存过期前,可能仍会显示旧内容。" +#: src/admin/pages/content-list.tsx +msgid "Pagination" +msgstr "分页" + +#: src/admin/pages/account.tsx #: src/admin/pages/login.tsx msgid "Password" msgstr "密码" +#: src/admin/pages/account.tsx +msgid "Passwords are hashed with PBKDF2-SHA256 at {iterations} iterations. Current guidance is {recommended}, but a sign-in has to finish inside the Cloudflare Free plan's 10 ms CPU budget, so the cost is capped." +msgstr "密码使用 PBKDF2-SHA256 哈希,迭代 {iterations} 次。目前的推荐值是 {recommended} 次,但登录必须在 Cloudflare 免费计划 10 毫秒的 CPU 预算内完成,所以迭代次数设了上限。" + +#: src/admin/pages/content-list.tsx +msgid "Path" +msgstr "路径" + #: src/admin/pages/settings-advanced.tsx msgid "Plugin on/off switches, settings and secrets" msgstr "插件的启用开关、设置和密钥" @@ -417,6 +635,11 @@ msgstr "插件" msgid "Prefix the default language too (<0>/{prefix}/…)" msgstr "默认语言也加前缀(<0>/{prefix}/…)" +#: src/admin/pages/content-list.tsx +msgid "Previous" +msgstr "上一页" + +#: src/admin/pages/content-list.tsx #: src/admin/pages/settings-advanced.tsx msgid "Published" msgstr "已发布" @@ -445,10 +668,23 @@ msgstr "已渲染片段" msgid "Resend API key" msgstr "Resend API 密钥" +#: src/admin/pages/account.tsx +msgid "Revoke" +msgstr "撤销" + +#: src/admin/tokens.ts +msgid "Revoked {revoked} · last used {lastUsed}" +msgstr "已于 {revoked} 撤销 · 最近使用于 {lastUsed}" + +#: src/admin/tokens.ts +msgid "Revoked {revoked} · never used" +msgstr "已于 {revoked} 撤销 · 从未使用" + #: src/admin/components/account-menu.tsx msgid "Same as the system" msgstr "跟随系统" +#: src/admin/components/media-library.tsx #: src/admin/pages/settings-advanced.tsx #: src/admin/pages/settings-site.tsx msgid "Save" @@ -485,6 +721,14 @@ msgstr "保存内容时会清除受影响页面的缓存,所以这是未被修 msgid "Saving…" msgstr "正在保存…" +#: src/admin/pages/content-list.tsx +msgid "Scheduled" +msgstr "定时发布" + +#: src/admin/pages/account.tsx +msgid "Scopes" +msgstr "权限范围" + #: src/admin/pages/settings-email.tsx msgid "Sender" msgstr "发件人" @@ -554,6 +798,10 @@ msgstr "站点名称" msgid "Site settings, languages, navigation" msgstr "站点设置、语言、导航" +#: src/admin/pages/content-list.tsx +msgid "Status" +msgstr "状态" + #: src/admin/pages/settings-advanced.tsx msgid "Storage" msgstr "存储" @@ -562,6 +810,10 @@ msgstr "存储" msgid "Stored encrypted. It is never shown again, here or anywhere else." msgstr "加密保存。之后在这里或任何地方都不会再显示。" +#: src/admin/media.ts +msgid "SVG is not accepted: it can carry script. Export a PNG or WebP instead." +msgstr "不支持 SVG:它可能携带脚本。请导出为 PNG 或 WebP。" + #: src/admin/pages/settings-advanced.tsx msgid "Switching to a different theme" msgstr "更换为其他主题" @@ -582,14 +834,26 @@ msgstr "检测" msgid "That did not work." msgstr "操作未成功。" +#: src/admin/tokens.ts +msgid "That token was already revoked." +msgstr "该令牌已被撤销。" + #: src/admin/pages/settings-advanced.tsx msgid "the {plugin} plugin" msgstr "{plugin} 插件" +#: src/admin/pages/content-list.tsx +msgid "The active theme does not declare this type, so it renders with the page layout. The content and its URL are untouched." +msgstr "当前主题没有声明这个类型,所以按普通页面的布局渲染。内容和 URL 都不受影响。" + #: src/admin/pages/settings-email.tsx msgid "The check failed." msgstr "检测失败。" +#: src/admin/pages/account.tsx +msgid "The CLI and any script use these. A token is shown once — copy it now, it cannot be retrieved later." +msgstr "CLI 和各种脚本都通过令牌访问。令牌只显示一次——请立即复制,之后无法再次查看。" + #: src/admin/pages/settings-site.tsx msgid "The default language has no URL prefix; every other language is served under <0>//." msgstr "默认语言不带 URL 前缀;其他语言都在 <0>// 下提供。" @@ -606,6 +870,11 @@ msgstr "以下选项是运行时设置:保存后立即生效,无需重新构 msgid "The site's admin" msgstr "站点后台" +#: src/admin/components/media-library.tsx +#: src/admin/media.ts +msgid "The upload failed." +msgstr "上传失败。" + #: src/admin/pages/settings-advanced.tsx msgid "Theme" msgstr "主题" @@ -630,14 +899,51 @@ msgstr "点击保存即生效——无需重新构建或部署。" msgid "These values apply to every language unless a language overrides them below." msgstr "这些值适用于所有语言,除非某个语言在下面单独设置。" +#: src/admin/pages/content-list.tsx +msgid "Title" +msgstr "标题" + +#: src/admin/pages/content-list.tsx +msgid "Type" +msgstr "类型" + +#: src/admin/media.ts +msgid "unknown type" +msgstr "未知类型" + +#: src/admin/components/media-library.tsx +msgid "unused" +msgstr "未使用" + +#: src/admin/pages/content-list.tsx +msgid "Updated" +msgstr "更新时间" + #: src/admin/pages/settings-advanced.tsx msgid "Upgrading Mallok itself" msgstr "升级 Mallok 本身" +#: src/admin/components/media-library.tsx +msgid "uploading" +msgstr "正在上传" + +#: src/admin/components/media-library.tsx +msgid "Use" +msgstr "使用" + +#: src/admin/pages/account.tsx +msgid "Use a long, unique password. For stronger protection, put Cloudflare Access in front of <0>/_mallok/." +msgstr "请使用足够长且不与其他地方重复的密码。如需更强的保护,可以在 <0>/_mallok/ 前面加上 Cloudflare Access。" + #: src/admin/pages/settings-email.tsx msgid "Use an address such as hello@example.com or Acme ." msgstr "请使用 hello@example.com 或 Acme 这样的地址。" +#. placeholder {0}: item.refCount +#: src/admin/components/media-library.tsx +msgid "used {0}×" +msgstr "已引用 {0} 次" + #: src/admin/pages/settings-appearance.tsx msgid "Values you change here apply only to {editingLocale}. Anything you leave alone follows the {editingDefaultLocale} value." msgstr "这里修改的值只对 {editingLocale} 生效。没有改动的选项沿用 {editingDefaultLocale} 的值。" diff --git a/src/admin/media.ts b/src/admin/media.ts index c6cbdb1..0374b8c 100644 --- a/src/admin/media.ts +++ b/src/admin/media.ts @@ -8,6 +8,7 @@ * byte for byte. */ +import { t } from '@lingui/core/macro'; import { api, csrf } from './api.js'; import type { MediaItem } from './types.js'; @@ -140,11 +141,12 @@ export async function uploadFile( if (file.type === 'image/svg+xml') { throw new Error( - 'SVG is not accepted: it can carry script. Export a PNG or WebP instead.', + t`SVG is not accepted: it can carry script. Export a PNG or WebP instead.`, ); } if (!ACCEPTED.has(file.type)) { - throw new Error(`"${file.type || 'unknown type'}" is not accepted.`); + const type = file.type === '' ? t`unknown type` : file.type; + throw new Error(t`"${type}" is not accepted.`); } const isImage = file.type.startsWith('image/'); @@ -181,7 +183,7 @@ export async function uploadFile( const body = (await response.json().catch(() => null)) as { error?: string; } | null; - throw new Error(body?.error ?? 'The upload failed.'); + throw new Error(body?.error ?? t`The upload failed.`); } if (bitmap !== null) { diff --git a/src/admin/pages/account.tsx b/src/admin/pages/account.tsx index c058d57..3b20111 100644 --- a/src/admin/pages/account.tsx +++ b/src/admin/pages/account.tsx @@ -6,11 +6,12 @@ */ import { zodResolver } from '@hookform/resolvers/zod'; +import { Trans, useLingui } from '@lingui/react/macro'; import { useQuery, useQueryClient } from '@tanstack/react-query'; import { cn } from 'cn'; import { Info, KeyRound } from 'lucide-react'; import type { JSX } from 'react'; -import { useState } from 'react'; +import { useMemo, useState } from 'react'; import { Controller, useForm } from 'react-hook-form'; import { z } from 'zod'; import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; @@ -59,14 +60,18 @@ const tokenSchema = z.object({ /** * The new password's length is checked here too, so the rule is read before - * the round trip; the server enforces it either way. + * the round trip; the server enforces it either way. The message is passed in + * so it is in the interface language. */ -const passwordSchema = z.object({ - currentPassword: z.string().min(1, REQUIRED_MESSAGE), - newPassword: z.string().min(12, 'At least 12 characters.'), -}); +function passwordSchema(tooShort: string) { + return z.object({ + currentPassword: z.string().min(1, REQUIRED_MESSAGE), + newPassword: z.string().min(12, tooShort), + }); +} export function AccountPage(): JSX.Element { + const { t } = useLingui(); const activeSession = useSession(); const client = useQueryClient(); const [minted, setMinted] = useState(''); @@ -81,7 +86,7 @@ export function AccountPage(): JSX.Element { queryKey: keys.tokens, queryFn: () => api<{ tokens: TokenSummary[] }>('/tokens'), }); - useReportError(listed.error, 'Could not load tokens.'); + useReportError(listed.error, t`Could not load tokens.`); const tokens = listed.data?.tokens ?? []; const reload = (): Promise => client.invalidateQueries({ queryKey: keys.tokens }); @@ -98,7 +103,9 @@ export function AccountPage(): JSX.Element { await reload(); } catch (caught) { showServerErrors(tokenForm.setError, caught); - notify(caught instanceof ApiError ? caught.message : 'Could not create.'); + notify( + caught instanceof ApiError ? caught.message : t`Could not create.`, + ); } }); @@ -112,13 +119,15 @@ export function AccountPage(): JSX.Element { await reload(); }; + const iterations = formatNumber(activeSession.passwordIterations); + const recommended = formatNumber(activeSession.passwordRecommendedIterations); const weakPassword = activeSession.passwordIterations < activeSession.passwordRecommendedIterations; return ( - + @@ -126,28 +135,30 @@ export function AccountPage(): JSX.Element { - About password hashing + About password hashing

      - Passwords are hashed with PBKDF2-SHA256 at{' '} - {formatNumber(activeSession.passwordIterations)} iterations. - Current guidance is{' '} - {formatNumber(activeSession.passwordRecommendedIterations)}, but a - sign-in has to finish inside the Cloudflare Free plan's 10 ms CPU - budget, so the cost is capped. + + Passwords are hashed with PBKDF2-SHA256 at {iterations}{' '} + iterations. Current guidance is {recommended}, but a sign-in has + to finish inside the Cloudflare Free plan's 10 ms CPU budget, so + the cost is capped. +

      - Use a long, unique password. For stronger protection, put - Cloudflare Access in front of /_mallok/. + + Use a long, unique password. For stronger protection, put + Cloudflare Access in front of /_mallok/. +

      ) : null}
      {minted === '' ? null : ( // A real alert: the token is on screen this once, and never again. @@ -165,7 +176,7 @@ export function AccountPage(): JSX.Element { void navigator.clipboard?.writeText(minted); }} > - Copy + Copy @@ -224,7 +235,7 @@ export function AccountPage(): JSX.Element { void revoke(token.id); }} > - Revoke + Revoke ) : null} @@ -238,7 +249,9 @@ export function AccountPage(): JSX.Element { onSubmit={(event) => void create(event)} > - New token name + + New token name + {nameError}
      - Scopes + + Scopes +
      @@ -295,8 +310,10 @@ export function AccountPage(): JSX.Element { } function PasswordSection(): JSX.Element { + const { t } = useLingui(); + const schema = useMemo(() => passwordSchema(t`At least 12 characters.`), [t]); const form = useForm({ - resolver: zodResolver(passwordSchema), + resolver: zodResolver(schema), defaultValues: { currentPassword: '', newPassword: '' }, }); const [done, setDone] = useState(false); @@ -314,7 +331,7 @@ function PasswordSection(): JSX.Element { notify( caught instanceof ApiError ? caught.message - : 'Could not change the password.', + : t`Could not change the password.`, ); } }); @@ -322,19 +339,25 @@ function PasswordSection(): JSX.Element { return (
      void submit(event)} footer={ <> - {done ? Changed : null} + {done ? ( + + Changed + + ) : null} } > - Current password + + Current password + - New password + + New password + > = { scheduled: 'warn', }; +/** A status as the list shows it; an unknown one is shown as stored. */ +const STATUS_LABELS: Readonly> = { + published: msg`Published`, + draft: msg`Draft`, + scheduled: msg`Scheduled`, +}; + export function ContentListPage(): JSX.Element { + const { t } = useLingui(); const site = useSettings(); const active = useTheme(); const navigate = useNavigate(); @@ -92,7 +103,7 @@ export function ContentListPage(): JSX.Element { `/content?${query.toString()}`, ), }); - useReportError(listed.error, 'Could not load content.'); + useReportError(listed.error, t`Could not load content.`); const items = listed.data?.items ?? []; const hasNext = listed.data?.hasNext ?? false; const loading = listed.isPending; @@ -102,7 +113,7 @@ export function ContentListPage(): JSX.Element { return ( } @@ -124,13 +135,15 @@ export function ContentListPage(): JSX.Element {
      - Type + + Type + filter('kind', event.currentTarget.value)} > - All + {t`All`} {kinds.map((entry) => ( {active.kinds[entry]?.label ?? entry} @@ -139,7 +152,9 @@ export function ContentListPage(): JSX.Element { - Language + + Language + - Status + + Status + filter('status', event.currentTarget.value)} > - All - Published - Draft - Scheduled + {t`All`} + {Object.entries(STATUS_LABELS).map(([value, label]) => ( + + {i18n._(label)} + + ))}
      {loading ? ( -

      Loading…

      +

      + Loading… +

      ) : items.length === 0 ? (

      - Nothing here yet. + Nothing here yet.

      ) : (
      @@ -179,19 +200,26 @@ export function ContentListPage(): JSX.Element { - Title + Title + + + Type + + + Status + + + Path - Type - Status - Path - Updated + Updated {items.map((item) => { const known = active.kinds[item.kind] !== undefined; + const statusLabel = STATUS_LABELS[item.status]; return ( @@ -208,16 +236,18 @@ export function ContentListPage(): JSX.Element { {known ? null : ( - Not in theme + Not in theme )} - {item.status} + {statusLabel === undefined + ? item.status + : i18n._(statusLabel)} @@ -239,14 +269,14 @@ export function ContentListPage(): JSX.Element {
      )} -
{loading ? ( -

Loading…

+

+ Loading… +

) : rows.length === 0 ? (

- Nothing here yet. + Nothing here yet.

) : (
@@ -275,7 +282,9 @@ export function PluginPanelView({ - Select + + Select + {panel.columns.map((column) => { const sorted = sort?.field === column.field; @@ -326,13 +335,18 @@ export function PluginPanelView({ ); })} - Details + + Details + {rows.map((row) => { const id = String(row.id ?? ''); + const rowName = String( + row[panel.columns[0]?.field ?? 'id'] ?? id, + ); return ( setSelected( @@ -362,15 +376,13 @@ export function PluginPanelView({ variant="outline" size="sm" aria-label={ - editable - ? `Edit ${String(row[panel.columns[0]?.field ?? 'id'] ?? id)}` - : `Open ${id}` + editable ? t`Edit ${rowName}` : t`Open ${id}` } onClick={() => editable ? setEditing(id) : setOpen(row) } > - {editable ? 'Edit' : 'Open'} + {editable ? t`Edit` : t`Open`} @@ -381,7 +393,7 @@ export function PluginPanelView({
)} -