From 9e1e628ab765de33a50dabcdcf91327e61c02993 Mon Sep 17 00:00:00 2001 From: m4 Date: Tue, 11 Aug 2026 14:52:56 +0800 Subject: [PATCH] feat(webui): next-intl scaffolding + en/zh catalog skeletons --- next.config.ts | 5 +- package-lock.json | 687 ++++++++++++++++++++++++++++- package.json | 1 + src/i18n/messages/en/chat.ts | 3 + src/i18n/messages/en/common.ts | 16 + src/i18n/messages/en/dialogs.ts | 3 + src/i18n/messages/en/errors.ts | 12 + src/i18n/messages/en/header.ts | 3 + src/i18n/messages/en/index.ts | 19 + src/i18n/messages/en/login.ts | 3 + src/i18n/messages/en/panels.ts | 3 + src/i18n/messages/en/threadList.ts | 3 + src/i18n/messages/messages.test.ts | 73 +++ src/i18n/messages/zh/chat.ts | 3 + src/i18n/messages/zh/common.ts | 16 + src/i18n/messages/zh/dialogs.ts | 3 + src/i18n/messages/zh/errors.ts | 12 + src/i18n/messages/zh/header.ts | 3 + src/i18n/messages/zh/index.ts | 19 + src/i18n/messages/zh/login.ts | 3 + src/i18n/messages/zh/panels.ts | 3 + src/i18n/messages/zh/threadList.ts | 3 + src/i18n/navigation.ts | 8 + src/i18n/request.ts | 14 + src/i18n/routing.ts | 9 + src/i18n/types.ts | 11 + src/lib/server/errorCodes.ts | 19 + 27 files changed, 954 insertions(+), 3 deletions(-) create mode 100644 src/i18n/messages/en/chat.ts create mode 100644 src/i18n/messages/en/common.ts create mode 100644 src/i18n/messages/en/dialogs.ts create mode 100644 src/i18n/messages/en/errors.ts create mode 100644 src/i18n/messages/en/header.ts create mode 100644 src/i18n/messages/en/index.ts create mode 100644 src/i18n/messages/en/login.ts create mode 100644 src/i18n/messages/en/panels.ts create mode 100644 src/i18n/messages/en/threadList.ts create mode 100644 src/i18n/messages/messages.test.ts create mode 100644 src/i18n/messages/zh/chat.ts create mode 100644 src/i18n/messages/zh/common.ts create mode 100644 src/i18n/messages/zh/dialogs.ts create mode 100644 src/i18n/messages/zh/errors.ts create mode 100644 src/i18n/messages/zh/header.ts create mode 100644 src/i18n/messages/zh/index.ts create mode 100644 src/i18n/messages/zh/login.ts create mode 100644 src/i18n/messages/zh/panels.ts create mode 100644 src/i18n/messages/zh/threadList.ts create mode 100644 src/i18n/navigation.ts create mode 100644 src/i18n/request.ts create mode 100644 src/i18n/routing.ts create mode 100644 src/i18n/types.ts create mode 100644 src/lib/server/errorCodes.ts diff --git a/next.config.ts b/next.config.ts index 0534584..4e6f963 100644 --- a/next.config.ts +++ b/next.config.ts @@ -1,4 +1,7 @@ import type { NextConfig } from "next"; +import createNextIntlPlugin from "next-intl/plugin"; + +const withNextIntl = createNextIntlPlugin("./src/i18n/request.ts"); const nextConfig: NextConfig = { // Self-contained server bundle for the npm package (the bin launcher runs @@ -13,4 +16,4 @@ const nextConfig: NextConfig = { }, }; -export default nextConfig; +export default withNextIntl(nextConfig); diff --git a/package-lock.json b/package-lock.json index 6fc71e4..f931288 100644 --- a/package-lock.json +++ b/package-lock.json @@ -30,6 +30,7 @@ "lucide-react": "^0.539.0", "mermaid": "^11.15.0", "next": "^16.2.5", + "next-intl": "^4.13.6", "nuqs": "^2.8.8", "react": "19.1.0", "react-dom": "19.1.0", @@ -1040,6 +1041,36 @@ "integrity": "sha512-RiB/yIh78pcIxl6lLMG0CgBXAZ2Y0eVHqMPYugu+9U0AeT6YBeiJpf7lbdJNIugFP5SIjwNRgo4DhR1Qxi26Gg==", "license": "MIT" }, + "node_modules/@formatjs/fast-memoize": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/@formatjs/fast-memoize/-/fast-memoize-3.1.7.tgz", + "integrity": "sha512-zXfhLpvA6T7+efdt9JLbBwZ00tT7NsBMDVnDu8rpHeNNv8KfRZAMo2gkG0k9lK/Nzc//3kJ9pImsfuJxk3KhUA==", + "license": "MIT" + }, + "node_modules/@formatjs/icu-messageformat-parser": { + "version": "3.5.16", + "resolved": "https://registry.npmjs.org/@formatjs/icu-messageformat-parser/-/icu-messageformat-parser-3.5.16.tgz", + "integrity": "sha512-kl6b/4D56gjGZi4ZewSmvXbalHwjOUI5ogEHPZqw42goeXTTrL7/yuPzvdrvr0QigDtvaOeb+UeMf62jks43Yg==", + "license": "MIT", + "dependencies": { + "@formatjs/icu-skeleton-parser": "2.1.11" + } + }, + "node_modules/@formatjs/icu-skeleton-parser": { + "version": "2.1.11", + "resolved": "https://registry.npmjs.org/@formatjs/icu-skeleton-parser/-/icu-skeleton-parser-2.1.11.tgz", + "integrity": "sha512-j8cUmOJzVgkHuS0QiQ6ga76UIoLOFSAMWhs7aZJztH3aAdCOAE6vpC8KVvFB4cU10ON0y2/5oOVmPJ43s2lTwA==", + "license": "MIT" + }, + "node_modules/@formatjs/intl-localematcher": { + "version": "0.8.13", + "resolved": "https://registry.npmjs.org/@formatjs/intl-localematcher/-/intl-localematcher-0.8.13.tgz", + "integrity": "sha512-kHEAFOkeJSPNi7c5PaKaRjxcBrJwzzt81ifUu+8uve1EDW/VJl83KsxmqgqNZLzcFEhSliZGvx3+pk/RH0IOmg==", + "license": "MIT", + "dependencies": { + "@formatjs/fast-memoize": "3.1.7" + } + }, "node_modules/@humanfs/core": { "version": "0.19.2", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", @@ -1948,6 +1979,292 @@ "node": ">=12.4.0" } }, + "node_modules/@parcel/watcher": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.6.0.tgz", + "integrity": "sha512-7FNeNl8NCE7aINx7WXiKQrPYZWC/hvrTsmk6zmxbI7LTXE7hVek/n8AfVgpe2y82zl3w0HvCHN0bVKMBoJcC0w==", + "hasInstallScript": true, + "license": "MIT", + "dependencies": { + "detect-libc": "^2.0.3", + "is-glob": "^4.0.3", + "node-addon-api": "^7.0.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "@parcel/watcher-android-arm64": "2.6.0", + "@parcel/watcher-darwin-arm64": "2.6.0", + "@parcel/watcher-darwin-x64": "2.6.0", + "@parcel/watcher-freebsd-x64": "2.6.0", + "@parcel/watcher-linux-arm-glibc": "2.6.0", + "@parcel/watcher-linux-arm-musl": "2.6.0", + "@parcel/watcher-linux-arm64-glibc": "2.6.0", + "@parcel/watcher-linux-arm64-musl": "2.6.0", + "@parcel/watcher-linux-x64-glibc": "2.6.0", + "@parcel/watcher-linux-x64-musl": "2.6.0", + "@parcel/watcher-win32-arm64": "2.6.0", + "@parcel/watcher-win32-x64": "2.6.0" + } + }, + "node_modules/@parcel/watcher-android-arm64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.6.0.tgz", + "integrity": "sha512-trgpLSCKRC/huFjXX/Smh+0sWe4+YtKfktIToiMl59ghz7z+qkH6kMvNnUbLyRs9N11t8l4svSCs1+5B3rOAhA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-arm64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.6.0.tgz", + "integrity": "sha512-Y3QV0gl7Q1zbfueunkWIERICbEojQFCgpyG7YqOGNFLsckXyI1xu9mAIUpKY9QBYzBtSkN8dBPwd3yiAO9ovMw==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-darwin-x64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.6.0.tgz", + "integrity": "sha512-Ohv6OpzhUfKYD7Beb8kDvG0jbIxORCYY1JRdZnaBtnjjkJxgD7ZVL0nw2sCYd0yTMKTvz3nnTnOF3cDifK+kvw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-freebsd-x64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.6.0.tgz", + "integrity": "sha512-5HmXvDgs8VK+74jF9y9/2FE3/OnlcKmc56tjmSrEuZjpSZOGL+fvAu+HKJBdPs9uwoP2hE6TlSUpXZ/C5jUFmQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-glibc": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.6.0.tgz", + "integrity": "sha512-Ps/hui3A+vMbjdqlqAowK2ZL8+BO8dBjxeWXj6npTBs3jx4wWmbPpaLuqwrQrSqIVMCnpWo238bJ1U37GhQOYg==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-musl": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.6.0.tgz", + "integrity": "sha512-9c6AUHgHoG+IY88MRIHupztQiQnrbqHYQjkM2btA+Bf/wQnQMuiD0Wfk1EVv3TlNT3x41uU71rn6E4xh/+zvkw==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-glibc": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.6.0.tgz", + "integrity": "sha512-yHRqS2owEXe6Hic9z6Mh1ECsCd+ODVOGvZDyciqRd21+v+o+DnXMOrw50DSpIG2sb8GPEaPPmfeCAWKPJdq46g==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm64-musl": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.6.0.tgz", + "integrity": "sha512-WhB2e/V7rqdHHWZusBSPuy5Ei8S6lSz6FE5TKKQz5h3a0O+C+mhY7vxU9b/stqvMb8beLnPY82ZrFTLKs+SrKA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-glibc": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.6.0.tgz", + "integrity": "sha512-ulGE6x6Oz6iAwg75T8YQSoguBWasniIbX+QWpaYPcCnDOpdWX3k+4xbEYPZVLxOuoJI+svJJPD3sEj8G7lrQ3A==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-x64-musl": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.6.0.tgz", + "integrity": "sha512-tkBYKt7YQrjIJWYDnto2YgO8MRkjlMTSNoRHzsXinBqbLdeOM3L32wPZJvIZxqaLMfSlS/4sUjH/6STVP/XDLw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-arm64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.6.0.tgz", + "integrity": "sha512-gIZAP23jaHjGWasY/TY6yL7NHFClf0Ga7FN+iINvk+KN94rhm94lYZhFsbYFNcA04/onvGD9kKmiJLJB2HbNwQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-win32-x64": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.6.0.tgz", + "integrity": "sha512-cA+/pXV2YkfxlIcXOQ5fSWqAzzPyD78/x5qbK/I0vUkrlYHA8TIz+MXjAbGouguKVSI4bOmkTSJ1/poVSsgt+A==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher/node_modules/picomatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.5.tgz", + "integrity": "sha512-RvwwcruNjI1ncT5xRakeyS9Lf8lcItv34KD+aif+VH9kduAyfYBipGh12274xtenIPZ119/R9BdTBa8gAwSh0A==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/@radix-ui/number": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@radix-ui/number/-/number-1.1.1.tgz", @@ -3872,6 +4189,210 @@ "dev": true, "license": "MIT" }, + "node_modules/@schummar/icu-type-parser": { + "version": "1.21.5", + "resolved": "https://registry.npmjs.org/@schummar/icu-type-parser/-/icu-type-parser-1.21.5.tgz", + "integrity": "sha512-bXHSaW5jRTmke9Vd0h5P7BtWZG9Znqb8gSDxZnxaGSJnGwPLDPfS+3g0BKzeWqzgZPsIVZkM7m2tbo18cm5HBw==", + "license": "MIT" + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.15.47.tgz", + "integrity": "sha512-GsoMtan3ojGGMGFbl31mmRu5ctZ56re8grGE8mO/OHJ8O+JRkzod02fe7X6ZQ8JvamA3imkEkx/h3u+vsOgPgA==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.15.47.tgz", + "integrity": "sha512-leTi7Rx3KF4zcC637iqWgk9SoV8VXAD8ppQYXsep63px5A/UftOcxLN1pmr8Z1si/YvX90ompP/rHgpYkgwXWg==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.15.47.tgz", + "integrity": "sha512-hBqHuoWKKIsKmDBn9qVeWqj5GWZhtlcczVaqQmNRXsDfq+voR5CxKRfamA367QjJXtceYuliLFfEL8QsskRM2g==", + "cpu": [ + "arm" + ], + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.15.47.tgz", + "integrity": "sha512-TBxvRz+B4K205TWHHZxWVxkC2RFNP/Mz3PNcECBos5PsKwxjg3QSJzdoebr0VCf0Bfh8HOPldKxAP/8XkFe9gA==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.15.47.tgz", + "integrity": "sha512-3Yu3Uq/VgytqsPjTMbkPU1ExADytbdWbruJYhA584E9jrpE2Ki+R6VVPoZCeAVk1Cb7QxcRTgblw6bSa6a/R+w==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-ppc64-gnu": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-linux-ppc64-gnu/-/core-linux-ppc64-gnu-1.15.47.tgz", + "integrity": "sha512-wfdMi5IaOaNtmh2/6geRoxIdNfqylUZFdtzTKS655y1axWfIWyx7As74vv0wVdjeCIZ3WmCI9odDd4rUttXOSQ==", + "cpu": [ + "ppc64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-s390x-gnu": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-linux-s390x-gnu/-/core-linux-s390x-gnu-1.15.47.tgz", + "integrity": "sha512-3hHYBY0yx8Ez7GMRrkhXHQzMdR5IZA6Wq5Ee4svlgwvSECLpnAJ9+0AimEGUFDvuLwE7nV/2+PYe8+Nm4rvNcQ==", + "cpu": [ + "s390x" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.15.47.tgz", + "integrity": "sha512-TjfhjgP/jGCfFHYC3JQPhJA1HwErbIJ9JfREDc1KNkvY6P0LodCgKVIlQ5deeTbkG7ih3bF5PHJLuLpaZjdRyQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.15.47.tgz", + "integrity": "sha512-CQpS8Ge/avfjZd0UEwG/sds83Uu32deQXcV1Jo3jD0mmvQQqtYAjpsDZXugmheeAwmt+YIuoVtVHro8LMYHqsQ==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.15.47.tgz", + "integrity": "sha512-0W8IKHsUTYiT7G2RqtOoVWk+89yzZikIiDUb/sCK6BmQDBhN91hQSfyUtW12jhEWLzYgcfmisfsZrmZE+84U1A==", + "cpu": [ + "arm64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.15.47.tgz", + "integrity": "sha512-ZIp49d2Z4/ka2jO9otOg4hDvTdPmp86kVOgS2M5FCPI7eKKZ1W0boxWn+8XeZrfERtFGW0AlMRm4JhlJa7l3NA==", + "cpu": [ + "ia32" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.15.47.tgz", + "integrity": "sha512-2h8Iek95vnixkBRCo+H8p09+Q5ll2NgSMFrWTy0iKt7+/t+8/T5mBpiT6c0ZxSS7wcWjwZ9sGZkK70tTSYHdDw==", + "cpu": [ + "x64" + ], + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==", + "license": "Apache-2.0" + }, "node_modules/@swc/helpers": { "version": "0.5.15", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.15.tgz", @@ -3881,6 +4402,15 @@ "tslib": "^2.8.0" } }, + "node_modules/@swc/types": { + "version": "0.1.28", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.28.tgz", + "integrity": "sha512-V6Mnml8v09QALx6K0elJ7o9K/MkVDtW3t6L+7Ou/JcWtb3xwId2AH4FeOceySd2JaO87IMw4+6vSZxLm34LPbw==", + "license": "Apache-2.0", + "dependencies": { + "@swc/counter": "^0.1.3" + } + }, "node_modules/@tailwindcss/forms": { "version": "0.5.11", "resolved": "https://registry.npmjs.org/@tailwindcss/forms/-/forms-0.5.11.tgz", @@ -8519,6 +9049,21 @@ "node": ">=0.10.0" } }, + "node_modules/icu-minify": { + "version": "4.13.6", + "resolved": "https://registry.npmjs.org/icu-minify/-/icu-minify-4.13.6.tgz", + "integrity": "sha512-iYZGCJZ+kX6o7GrxpVe2sOSdW86AvEqh8RQBvWeBd9jqmuABsMc2B6xongACfItLOogyIWH6GuBslNHr79OU8Q==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/amannn" + } + ], + "license": "MIT", + "dependencies": { + "@formatjs/icu-messageformat-parser": "^3.4.0" + } + }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -8634,6 +9179,16 @@ "node": ">=12" } }, + "node_modules/intl-messageformat": { + "version": "11.2.13", + "resolved": "https://registry.npmjs.org/intl-messageformat/-/intl-messageformat-11.2.13.tgz", + "integrity": "sha512-JaPaE6TIX+TAS5XLhDUh41geLw4QfBHX4s5pW8Km+L9fVC8HzB9yOuhbh4EMR/F1+8C6b9qk4763Cv+LdOG1kg==", + "license": "BSD-3-Clause", + "dependencies": { + "@formatjs/fast-memoize": "3.1.7", + "@formatjs/icu-messageformat-parser": "3.5.16" + } + }, "node_modules/is-alphabetical": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-2.0.1.tgz", @@ -8843,7 +9398,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -8889,7 +9443,6 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", - "dev": true, "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" @@ -10649,6 +11202,15 @@ "dev": true, "license": "MIT" }, + "node_modules/negotiator": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz", + "integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/next": { "version": "16.2.6", "resolved": "https://registry.npmjs.org/next/-/next-16.2.6.tgz", @@ -10702,6 +11264,94 @@ } } }, + "node_modules/next-intl": { + "version": "4.13.6", + "resolved": "https://registry.npmjs.org/next-intl/-/next-intl-4.13.6.tgz", + "integrity": "sha512-loS6tjWWkr/IP+EV1yXUm9URB54QmZOp4+ZsMZNmeYxY8IZxLvO2esUegnXIDxj5DpK/4BsxwDGfGhlqodpkCQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/amannn" + } + ], + "license": "MIT", + "dependencies": { + "@formatjs/intl-localematcher": "^0.8.1", + "@parcel/watcher": "^2.4.1", + "@swc/core": "^1.15.2", + "icu-minify": "^4.13.6", + "negotiator": "^1.0.0", + "next-intl-swc-plugin-extractor": "^4.13.6", + "po-parser": "^2.1.1", + "use-intl": "^4.13.6" + }, + "peerDependencies": { + "next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0", + "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/next-intl-swc-plugin-extractor": { + "version": "4.13.6", + "resolved": "https://registry.npmjs.org/next-intl-swc-plugin-extractor/-/next-intl-swc-plugin-extractor-4.13.6.tgz", + "integrity": "sha512-M2L8jtPEAXj0CPmXbiW66THdr3OnDqA9IsU1hqv3CdxtVow3Bl9eXPdT9Opeji7L4AFrUZ016dJOs+CoTw66OA==", + "license": "MIT" + }, + "node_modules/next-intl/node_modules/@swc/core": { + "version": "1.15.47", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.15.47.tgz", + "integrity": "sha512-FbsO5JcfOjfH38W/rohBRBweJeERsAuIP4f377lmkmxTcq9exjtx4SkRuZY5CdfhR2CBVwDIJegBpJDffwNsOg==", + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@swc/counter": "^0.1.3", + "@swc/types": "^0.1.27" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.15.47", + "@swc/core-darwin-x64": "1.15.47", + "@swc/core-linux-arm-gnueabihf": "1.15.47", + "@swc/core-linux-arm64-gnu": "1.15.47", + "@swc/core-linux-arm64-musl": "1.15.47", + "@swc/core-linux-ppc64-gnu": "1.15.47", + "@swc/core-linux-s390x-gnu": "1.15.47", + "@swc/core-linux-x64-gnu": "1.15.47", + "@swc/core-linux-x64-musl": "1.15.47", + "@swc/core-win32-arm64-msvc": "1.15.47", + "@swc/core-win32-ia32-msvc": "1.15.47", + "@swc/core-win32-x64-msvc": "1.15.47" + }, + "peerDependencies": { + "@swc/helpers": ">=0.5.17" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/next-intl/node_modules/@swc/helpers": { + "version": "0.5.23", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.23.tgz", + "integrity": "sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==", + "license": "Apache-2.0", + "optional": true, + "peer": true, + "dependencies": { + "tslib": "^2.8.0" + } + }, "node_modules/next/node_modules/postcss": { "version": "8.4.31", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz", @@ -10754,6 +11404,12 @@ "node": ">=10" } }, + "node_modules/node-addon-api": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", + "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", + "license": "MIT" + }, "node_modules/node-exports-info": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/node-exports-info/-/node-exports-info-1.6.0.tgz", @@ -11247,6 +11903,12 @@ "node": ">= 6" } }, + "node_modules/po-parser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/po-parser/-/po-parser-2.1.1.tgz", + "integrity": "sha512-ECF4zHLbUItpUgE3OTtLKlPjeBN+fKEczj2zYjDfCGOzicNs0GK3Vg2IoAYwx7LH/XYw43fZQP6xnZ4TkNxSLQ==", + "license": "MIT" + }, "node_modules/points-on-curve": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/points-on-curve/-/points-on-curve-0.2.0.tgz", @@ -13796,6 +14458,27 @@ } } }, + "node_modules/use-intl": { + "version": "4.13.6", + "resolved": "https://registry.npmjs.org/use-intl/-/use-intl-4.13.6.tgz", + "integrity": "sha512-RLej84qL6PGTDp/PSG3tqRpwr7IvJfOu4Qfv/uyy8CrnYn1oEOQb6osNJb++jZ7FQxqN3aQ5BI7wTIerUgrgMA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/amannn" + } + ], + "license": "MIT", + "dependencies": { + "@formatjs/fast-memoize": "^3.1.0", + "@schummar/icu-type-parser": "1.21.5", + "icu-minify": "^4.13.6", + "intl-messageformat": "^11.1.0" + }, + "peerDependencies": { + "react": "^17.0.0 || ^18.0.0 || >=19.0.0-rc <19.0.0 || ^19.0.0" + } + }, "node_modules/use-sidecar": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/use-sidecar/-/use-sidecar-1.1.3.tgz", diff --git a/package.json b/package.json index 698799c..9366cdc 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,7 @@ "lucide-react": "^0.539.0", "mermaid": "^11.15.0", "next": "^16.2.5", + "next-intl": "^4.13.6", "nuqs": "^2.8.8", "react": "19.1.0", "react-dom": "19.1.0", diff --git a/src/i18n/messages/en/chat.ts b/src/i18n/messages/en/chat.ts new file mode 100644 index 0000000..5c34883 --- /dev/null +++ b/src/i18n/messages/en/chat.ts @@ -0,0 +1,3 @@ +export default { + chat: {}, +}; diff --git a/src/i18n/messages/en/common.ts b/src/i18n/messages/en/common.ts new file mode 100644 index 0000000..1d911b8 --- /dev/null +++ b/src/i18n/messages/en/common.ts @@ -0,0 +1,16 @@ +export default { + common: { + loading: "Loading…", + save: "Save", + cancel: "Cancel", + close: "Close", + delete: "Delete", + confirm: "Confirm", + retry: "Retry", + copy: "Copy", + copied: "Copied", + notFound: "Page not found.", + metadataDescription: + "Web UI for EvoScientist — a self-evolving AI scientist built on DeepAgents/LangGraph.", + }, +}; diff --git a/src/i18n/messages/en/dialogs.ts b/src/i18n/messages/en/dialogs.ts new file mode 100644 index 0000000..ca7ee4e --- /dev/null +++ b/src/i18n/messages/en/dialogs.ts @@ -0,0 +1,3 @@ +export default { + dialogs: {}, +}; diff --git a/src/i18n/messages/en/errors.ts b/src/i18n/messages/en/errors.ts new file mode 100644 index 0000000..db3c00a --- /dev/null +++ b/src/i18n/messages/en/errors.ts @@ -0,0 +1,12 @@ +export default { + errors: { + INVALID_REQUEST: "The request is invalid.", + UNAUTHENTICATED: "Your session has expired. Please sign in again.", + FORBIDDEN: "You don't have permission to do this.", + NOT_FOUND: "The requested resource was not found.", + PAYLOAD_TOO_LARGE: "The upload is too large.", + UNSUPPORTED_MEDIA_TYPE: "This file type is not supported.", + CONFLICT: "This conflicts with the current state. Refresh and try again.", + INTERNAL: "Something went wrong on the server. Please try again.", + }, +}; diff --git a/src/i18n/messages/en/header.ts b/src/i18n/messages/en/header.ts new file mode 100644 index 0000000..a77dd52 --- /dev/null +++ b/src/i18n/messages/en/header.ts @@ -0,0 +1,3 @@ +export default { + header: {}, +}; diff --git a/src/i18n/messages/en/index.ts b/src/i18n/messages/en/index.ts new file mode 100644 index 0000000..31c906a --- /dev/null +++ b/src/i18n/messages/en/index.ts @@ -0,0 +1,19 @@ +import common from "./common"; +import header from "./header"; +import threadList from "./threadList"; +import chat from "./chat"; +import dialogs from "./dialogs"; +import panels from "./panels"; +import login from "./login"; +import errors from "./errors"; + +export default { + ...common, + ...header, + ...threadList, + ...chat, + ...dialogs, + ...panels, + ...login, + ...errors, +}; diff --git a/src/i18n/messages/en/login.ts b/src/i18n/messages/en/login.ts new file mode 100644 index 0000000..7643adb --- /dev/null +++ b/src/i18n/messages/en/login.ts @@ -0,0 +1,3 @@ +export default { + login: {}, +}; diff --git a/src/i18n/messages/en/panels.ts b/src/i18n/messages/en/panels.ts new file mode 100644 index 0000000..de2d1bc --- /dev/null +++ b/src/i18n/messages/en/panels.ts @@ -0,0 +1,3 @@ +export default { + panels: {}, +}; diff --git a/src/i18n/messages/en/threadList.ts b/src/i18n/messages/en/threadList.ts new file mode 100644 index 0000000..b4e882c --- /dev/null +++ b/src/i18n/messages/en/threadList.ts @@ -0,0 +1,3 @@ +export default { + threadList: {}, +}; diff --git a/src/i18n/messages/messages.test.ts b/src/i18n/messages/messages.test.ts new file mode 100644 index 0000000..994d216 --- /dev/null +++ b/src/i18n/messages/messages.test.ts @@ -0,0 +1,73 @@ +import { describe, expect, it, vi } from "vitest"; +import en from "./en"; +import zh from "./zh"; +import enCommon from "./en/common"; +import enHeader from "./en/header"; +import enThreadList from "./en/threadList"; +import enChat from "./en/chat"; +import enDialogs from "./en/dialogs"; +import enPanels from "./en/panels"; +import enLogin from "./en/login"; +import enErrors from "./en/errors"; + +vi.mock("server-only", () => ({})); + +const { API_ERROR_CODES } = await import("@/lib/server/errorCodes"); + +type Tree = Record; + +function leafPaths(tree: Tree, prefix = ""): string[] { + return Object.entries(tree).flatMap(([key, value]) => { + const path = prefix ? `${prefix}.${key}` : key; + if (value !== null && typeof value === "object") { + return leafPaths(value as Tree, path); + } + return [path]; + }); +} + +function leafAt(tree: Tree, path: string): string { + let node: unknown = tree; + for (const key of path.split(".")) node = (node as Tree)[key]; + return node as string; +} + +function icuVars(message: string): string[] { + return [...message.matchAll(/\{(\w+)[,}]/g)].map((m) => m[1]).sort(); +} + +describe("message catalogs", () => { + it("en and zh have identical key sets", () => { + expect(leafPaths(zh).sort()).toEqual(leafPaths(en).sort()); + }); + + it("each leaf has the same ICU variables in both locales", () => { + for (const path of leafPaths(en)) { + expect(icuVars(leafAt(zh, path)), path).toEqual( + icuVars(leafAt(en, path)) + ); + } + }); + + it("domain modules do not shadow each other at the top level", () => { + const modules = [ + enCommon, + enHeader, + enThreadList, + enChat, + enDialogs, + enPanels, + enLogin, + enErrors, + ]; + const total = modules.reduce((n, m) => n + Object.keys(m).length, 0); + expect(Object.keys(en).length).toBe(total); + }); + + it("errors.* covers every code the WebUI API can emit", () => { + const errors = (en as unknown as Tree).errors as Tree; + for (const code of API_ERROR_CODES) { + expect(typeof errors[code], code).toBe("string"); + } + }); +}); diff --git a/src/i18n/messages/zh/chat.ts b/src/i18n/messages/zh/chat.ts new file mode 100644 index 0000000..5c34883 --- /dev/null +++ b/src/i18n/messages/zh/chat.ts @@ -0,0 +1,3 @@ +export default { + chat: {}, +}; diff --git a/src/i18n/messages/zh/common.ts b/src/i18n/messages/zh/common.ts new file mode 100644 index 0000000..05b3b31 --- /dev/null +++ b/src/i18n/messages/zh/common.ts @@ -0,0 +1,16 @@ +export default { + common: { + loading: "加载中…", + save: "保存", + cancel: "取消", + close: "关闭", + delete: "删除", + confirm: "确认", + retry: "重试", + copy: "复制", + copied: "已复制", + notFound: "页面不存在。", + metadataDescription: + "EvoScientist 的 Web 界面 —— 一个基于 DeepAgents/LangGraph 的自我进化 AI 科学家。", + }, +}; diff --git a/src/i18n/messages/zh/dialogs.ts b/src/i18n/messages/zh/dialogs.ts new file mode 100644 index 0000000..ca7ee4e --- /dev/null +++ b/src/i18n/messages/zh/dialogs.ts @@ -0,0 +1,3 @@ +export default { + dialogs: {}, +}; diff --git a/src/i18n/messages/zh/errors.ts b/src/i18n/messages/zh/errors.ts new file mode 100644 index 0000000..04fbfae --- /dev/null +++ b/src/i18n/messages/zh/errors.ts @@ -0,0 +1,12 @@ +export default { + errors: { + INVALID_REQUEST: "请求无效。", + UNAUTHENTICATED: "登录已过期,请重新登录。", + FORBIDDEN: "没有执行此操作的权限。", + NOT_FOUND: "请求的资源不存在。", + PAYLOAD_TOO_LARGE: "上传内容过大。", + UNSUPPORTED_MEDIA_TYPE: "不支持的文件类型。", + CONFLICT: "与当前状态冲突,请刷新后重试。", + INTERNAL: "服务器出错,请稍后重试。", + }, +}; diff --git a/src/i18n/messages/zh/header.ts b/src/i18n/messages/zh/header.ts new file mode 100644 index 0000000..a77dd52 --- /dev/null +++ b/src/i18n/messages/zh/header.ts @@ -0,0 +1,3 @@ +export default { + header: {}, +}; diff --git a/src/i18n/messages/zh/index.ts b/src/i18n/messages/zh/index.ts new file mode 100644 index 0000000..31c906a --- /dev/null +++ b/src/i18n/messages/zh/index.ts @@ -0,0 +1,19 @@ +import common from "./common"; +import header from "./header"; +import threadList from "./threadList"; +import chat from "./chat"; +import dialogs from "./dialogs"; +import panels from "./panels"; +import login from "./login"; +import errors from "./errors"; + +export default { + ...common, + ...header, + ...threadList, + ...chat, + ...dialogs, + ...panels, + ...login, + ...errors, +}; diff --git a/src/i18n/messages/zh/login.ts b/src/i18n/messages/zh/login.ts new file mode 100644 index 0000000..7643adb --- /dev/null +++ b/src/i18n/messages/zh/login.ts @@ -0,0 +1,3 @@ +export default { + login: {}, +}; diff --git a/src/i18n/messages/zh/panels.ts b/src/i18n/messages/zh/panels.ts new file mode 100644 index 0000000..de2d1bc --- /dev/null +++ b/src/i18n/messages/zh/panels.ts @@ -0,0 +1,3 @@ +export default { + panels: {}, +}; diff --git a/src/i18n/messages/zh/threadList.ts b/src/i18n/messages/zh/threadList.ts new file mode 100644 index 0000000..b4e882c --- /dev/null +++ b/src/i18n/messages/zh/threadList.ts @@ -0,0 +1,3 @@ +export default { + threadList: {}, +}; diff --git a/src/i18n/navigation.ts b/src/i18n/navigation.ts new file mode 100644 index 0000000..8094814 --- /dev/null +++ b/src/i18n/navigation.ts @@ -0,0 +1,8 @@ +import { createNavigation } from "next-intl/navigation"; +import { routing } from "./routing"; + +// Locale-aware wrappers around Next.js navigation APIs. The codebase's +// existing navigation is window.location-based (see src/lib/localePath.ts); +// these are used by LocaleSwitcher and any future SPA navigation. +export const { Link, redirect, usePathname, useRouter, getPathname } = + createNavigation(routing); diff --git a/src/i18n/request.ts b/src/i18n/request.ts new file mode 100644 index 0000000..0b43244 --- /dev/null +++ b/src/i18n/request.ts @@ -0,0 +1,14 @@ +import { getRequestConfig } from "next-intl/server"; +import { hasLocale } from "next-intl"; +import { routing } from "./routing"; + +export default getRequestConfig(async ({ requestLocale }) => { + const requested = await requestLocale; + const locale = hasLocale(routing.locales, requested) + ? requested + : routing.defaultLocale; + return { + locale, + messages: (await import(`./messages/${locale}/index.ts`)).default, + }; +}); diff --git a/src/i18n/routing.ts b/src/i18n/routing.ts new file mode 100644 index 0000000..6da5874 --- /dev/null +++ b/src/i18n/routing.ts @@ -0,0 +1,9 @@ +import { defineRouting } from "next-intl/routing"; + +export const routing = defineRouting({ + locales: ["en", "zh"], + defaultLocale: "en", + localePrefix: "always", +}); + +export type Locale = (typeof routing.locales)[number]; diff --git a/src/i18n/types.ts b/src/i18n/types.ts new file mode 100644 index 0000000..fe5cfce --- /dev/null +++ b/src/i18n/types.ts @@ -0,0 +1,11 @@ +import type { routing } from "./routing"; +import type en from "./messages/en"; + +// Makes useTranslations()/getTranslations() key-checked against the en +// catalog — key typos become compile errors (spec §2). +declare module "next-intl" { + interface AppConfig { + Locale: (typeof routing.locales)[number]; + Messages: typeof en; + } +} diff --git a/src/lib/server/errorCodes.ts b/src/lib/server/errorCodes.ts new file mode 100644 index 0000000..f26f617 --- /dev/null +++ b/src/lib/server/errorCodes.ts @@ -0,0 +1,19 @@ +import "server-only"; + +// Stable error codes emitted by WebUI API routes (spec §4). Clients map these +// to localized strings via the errors.* catalog; the English `message` field +// remains the fallback. Python-backend codes are forwarded separately by +// routeErrorResponse and are NOT part of this set. Task 7 may append auth +// codes (e.g. INVALID_CREDENTIALS) discovered during route unification. +export const API_ERROR_CODES = [ + "INVALID_REQUEST", + "UNAUTHENTICATED", + "FORBIDDEN", + "NOT_FOUND", + "PAYLOAD_TOO_LARGE", + "UNSUPPORTED_MEDIA_TYPE", + "CONFLICT", + "INTERNAL", +] as const; + +export type ApiErrorCode = (typeof API_ERROR_CODES)[number];