From dda4b98ba4e98db1ba2128270073feea0049212a Mon Sep 17 00:00:00 2001 From: jwcub Date: Sat, 2 Mar 2024 09:05:55 +0800 Subject: [PATCH] fix: i18n --- .github/workflows/test.yml | 2 +- app/entry.client.tsx | 5 - app/entry.server.tsx | 10 +- app/i18n/i18n.ts | 19 +- app/i18n/i18next.d.ts | 8 +- app/i18n/i18next.server.ts | 11 +- app/theme/global.less | 2 - package-lock.json | 223 +++++++----------- package.json | 2 - prisma/seed.ts | 2 +- .../en/Insider Preview #46 Has Started.md | 0 .../articles}/en/Welcome to polygen.md | 0 ...77\216\346\235\245\345\210\260 polygen.md" | 0 ...13\345\267\262\345\274\200\345\247\213.md" | 0 .../locales/en.json | 0 .../locales/zh.json | 0 {public => static/public}/favicon.ico | Bin {public => static/public}/robots.txt | 0 vite.config.ts | 9 +- 19 files changed, 112 insertions(+), 181 deletions(-) rename {articles => static/articles}/en/Insider Preview #46 Has Started.md (100%) rename {articles => static/articles}/en/Welcome to polygen.md (100%) rename "articles/zh/\346\254\242\350\277\216\346\235\245\345\210\260 polygen.md" => "static/articles/zh/\346\254\242\350\277\216\346\235\245\345\210\260 polygen.md" (100%) rename "articles/zh/\347\254\254 46 \346\254\241\345\206\205\346\265\213\345\267\262\345\274\200\345\247\213.md" => "static/articles/zh/\347\254\254 46 \346\254\241\345\206\205\346\265\213\345\267\262\345\274\200\345\247\213.md" (100%) rename public/locales/en/translation.json => static/locales/en.json (100%) rename public/locales/zh/translation.json => static/locales/zh.json (100%) rename {public => static/public}/favicon.ico (100%) rename {public => static/public}/robots.txt (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7bc099d..9a99a47 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ concurrency: cancel-in-progress: true jobs: - bench: + test: runs-on: ubuntu-latest steps: - name: ⬇️ Checkout repo diff --git a/app/entry.client.tsx b/app/entry.client.tsx index e91a0f3..ca4d5a7 100644 --- a/app/entry.client.tsx +++ b/app/entry.client.tsx @@ -3,7 +3,6 @@ import { CacheProvider } from "@emotion/react"; import { RemixBrowser } from "@remix-run/react"; import i18next from "i18next"; import LanguageDetector from "i18next-browser-languagedetector"; -import Backend from "i18next-http-backend"; import { startTransition, StrictMode } from "react"; import { hydrateRoot } from "react-dom/client"; import { I18nextProvider, initReactI18next } from "react-i18next"; @@ -17,12 +16,8 @@ const cache = createCache({ key: "-", stylisPlugins: [] }); i18next .use(initReactI18next) .use(LanguageDetector) - .use(Backend) .init({ ...i18n, - backend: { - loadPath: "/locales/{{lng}}/{{ns}}.json" - }, detection: { order: ["cookie", "htmlTag"], caches: ["cookie"], diff --git a/app/entry.server.tsx b/app/entry.server.tsx index 1c3d539..ab0c9fb 100644 --- a/app/entry.server.tsx +++ b/app/entry.server.tsx @@ -1,4 +1,3 @@ -import { resolve } from "node:path"; import { PassThrough } from "node:stream"; import createCache from "@emotion/cache"; @@ -11,7 +10,6 @@ import type { import { createReadableStreamFromReadable } from "@remix-run/node"; import { RemixServer } from "@remix-run/react"; import i18next from "i18next"; -import Backend from "i18next-fs-backend"; import { isbot } from "isbot"; import { renderToPipeableStream } from "react-dom/server"; import { I18nextProvider, initReactI18next } from "react-i18next"; @@ -28,13 +26,7 @@ import { getLocale } from "./i18n/i18next.server"; const ABORT_DELAY = 6590; // Set up i18next server backend. -await i18next - .use(initReactI18next) - .use(Backend) - .init({ - ...i18n, - backend: { loadPath: resolve("./public/locales/{{lng}}/{{ns}}.json") } - }); +await i18next.use(initReactI18next).init(i18n); /** * Handles incoming requests. diff --git a/app/i18n/i18n.ts b/app/i18n/i18n.ts index 5df6582..1cb5ab9 100644 --- a/app/i18n/i18n.ts +++ b/app/i18n/i18n.ts @@ -1,10 +1,25 @@ import type { ServerRuntimeMetaArgs } from "@remix-run/server-runtime"; +import type { InitOptions } from "i18next"; import { getFixedT } from "i18next"; +import en from "@/static/locales/en.json"; +import zh from "@/static/locales/zh.json"; + +const ns = "translations"; + export default { supportedLngs: ["zh", "en"], - fallbackLng: "en" -}; + fallbackLng: "en", + ns, + resources: { + en: { + [ns]: en + }, + zh: { + [ns]: zh + } + } +} satisfies InitOptions; export function getT( matches: ServerRuntimeMetaArgs["matches"] diff --git a/app/i18n/i18next.d.ts b/app/i18n/i18next.d.ts index dd38ede..0eb8c61 100644 --- a/app/i18n/i18next.d.ts +++ b/app/i18n/i18next.d.ts @@ -1,14 +1,16 @@ import type { ParseKeys } from "i18next"; -import type translation from "@/public/locales/en/translation.json"; +import type translation from "@/static/locales/en.json"; + +import type i18n from "./i18n"; declare module "i18next" { interface CustomTypeOptions { - defaultNS: "translation"; + defaultNS: i18n.ns; resources: { translation: typeof translation; }; } } -type TFunctionArg = ParseKeys<"translation">; +type TFunctionArg = ParseKeys; diff --git a/app/i18n/i18next.server.ts b/app/i18n/i18next.server.ts index 73a5b4d..1457e9a 100644 --- a/app/i18n/i18next.server.ts +++ b/app/i18n/i18next.server.ts @@ -1,6 +1,3 @@ -import { resolve } from "node:path"; - -import Backend from "i18next-fs-backend"; import { RemixI18Next } from "remix-i18next/server"; import { getCookieValue } from "~/hooks/cookie"; @@ -13,13 +10,7 @@ export const i18next = new RemixI18Next({ fallbackLanguage: i18n.fallbackLng, order: ["cookie", "header"] }, - i18next: { - ...i18n, - backend: { - loadPath: resolve("./public/locales/{{lng}}/{{ns}}.json") - } - }, - plugins: [Backend] + i18next: i18n }); const I18NEXT_KEY = "i18next"; diff --git a/app/theme/global.less b/app/theme/global.less index de6e14a..5628f60 100644 --- a/app/theme/global.less +++ b/app/theme/global.less @@ -1,6 +1,4 @@ p { - margin-top: 1rem; - &:first-child { margin-top: 0; } diff --git a/package-lock.json b/package-lock.json index 266ebde..757d5b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,8 +35,6 @@ "fs-extra": "latest", "i18next": "latest", "i18next-browser-languagedetector": "latest", - "i18next-fs-backend": "latest", - "i18next-http-backend": "latest", "isbot": "latest", "katex": "latest", "lodash": "latest", @@ -2077,9 +2075,9 @@ } }, "node_modules/@cspell/cspell-bundled-dicts": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-8.4.1.tgz", - "integrity": "sha512-rOMupwDktbAAFfc6X/VCNl0nNFL7kH/G2KuZF3VCpXR6YR8FsQjbl1WLmEd0zVVeO+JWM99JcZS2OO/HAR3www==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-8.5.0.tgz", + "integrity": "sha512-bwiu+D3UZlLn4buaehtkn8BuVEMtJcmfudci5/NmbuSwS1ayzl17T76D4R2e1kalad0cR+yYMrd+eshMx3loaw==", "dev": true, "dependencies": { "@cspell/dict-ada": "^4.0.2", @@ -2095,7 +2093,7 @@ "@cspell/dict-docker": "^1.1.7", "@cspell/dict-dotnet": "^5.0.0", "@cspell/dict-elixir": "^4.0.3", - "@cspell/dict-en_us": "^4.3.16", + "@cspell/dict-en_us": "^4.3.17", "@cspell/dict-en-common-misspellings": "^2.0.0", "@cspell/dict-en-gb": "1.1.33", "@cspell/dict-filetypes": "^3.0.3", @@ -2118,7 +2116,7 @@ "@cspell/dict-npm": "^5.0.15", "@cspell/dict-php": "^4.0.6", "@cspell/dict-powershell": "^5.0.3", - "@cspell/dict-public-licenses": "^2.0.5", + "@cspell/dict-public-licenses": "^2.0.6", "@cspell/dict-python": "^4.1.11", "@cspell/dict-r": "^2.0.1", "@cspell/dict-ruby": "^5.0.2", @@ -2136,18 +2134,18 @@ } }, "node_modules/@cspell/cspell-pipe": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/@cspell/cspell-pipe/-/cspell-pipe-8.4.1.tgz", - "integrity": "sha512-xlIcZpqZni4eznazDIs1sJB38r0jH5nnbsLu0Y1LeRXmznyRv5xma6J/4jkQmVAsF2DmVWOqJeKwQqpVB5lHzw==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/@cspell/cspell-pipe/-/cspell-pipe-8.5.0.tgz", + "integrity": "sha512-PDg6TgH4COs/v5dq+Isfxzk8omuJ86bZBR9UCuK2zwn5EsGouAPsdcFoNLcEdDkjKLObGzM0o9XSj0/TdaOmIQ==", "dev": true, "engines": { "node": ">=18" } }, "node_modules/@cspell/cspell-resolver": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/@cspell/cspell-resolver/-/cspell-resolver-8.4.1.tgz", - "integrity": "sha512-rerJ013neN4NMw5EeJNmAiPdkHimwLndoEGhzQi9Yz7oCV78oq9wxK6H6UNZt8oveJG3Utj7hTYRzUyswKneNg==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/@cspell/cspell-resolver/-/cspell-resolver-8.5.0.tgz", + "integrity": "sha512-zv1lk21OneXuAF4wWe1eEw9zTMJCRUQifslM3IuzfcpahttgjLSfCiFv0x58YqCwtY7hD4M+vwXHmxV5p1Q/5g==", "dev": true, "dependencies": { "global-directory": "^4.0.1" @@ -2157,18 +2155,18 @@ } }, "node_modules/@cspell/cspell-service-bus": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/@cspell/cspell-service-bus/-/cspell-service-bus-8.4.1.tgz", - "integrity": "sha512-pr5bd5bM46vmD4UN/l1rS7VGCkgPTwrwBB+4IWYAztnDtOOoTzPtzIVBKbamaEru7Wabwna/lICntVlmiBNbhQ==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/@cspell/cspell-service-bus/-/cspell-service-bus-8.5.0.tgz", + "integrity": "sha512-GnCK2jSWflvvHUurwCxVxJpupr3G1xAUeUNG1R3+sFRF51/kZ2ZtjJxUOby1a3lyHLBte4o6N3GbqxFFvh27nw==", "dev": true, "engines": { "node": ">=18" } }, "node_modules/@cspell/cspell-types": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/@cspell/cspell-types/-/cspell-types-8.4.1.tgz", - "integrity": "sha512-z/bU98oLtii2xGKO5zYhpElAUUh6x6PmKPIulDfPu+3MItjLWdNxzD5OWNSg9iv0sZbWQCQ3lOMNX2EF+8QyUA==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/@cspell/cspell-types/-/cspell-types-8.5.0.tgz", + "integrity": "sha512-2C7BFF9TzQsA0972/TriDRtwD5X1UUuSNWZ/NCpWzgZAw9JXmTIXj6D5QQWq2fcQ2KzcKaEeL6TanOl2iZfxlA==", "dev": true, "engines": { "node": ">=18" @@ -2472,9 +2470,9 @@ "dev": true }, "node_modules/@cspell/dynamic-import": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/@cspell/dynamic-import/-/dynamic-import-8.4.1.tgz", - "integrity": "sha512-H+zZ7MpoiJyZ9zMdifsF/uBWOsovwWr40MBW+f1Tgpu2H6e3A1knRvxRy52fEK8eVhANrGVPVVZix4lI1XtBsw==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/@cspell/dynamic-import/-/dynamic-import-8.5.0.tgz", + "integrity": "sha512-IBrPx+Eo1yZF43oY4Iy5ESGsVkhHrfbYNcOAwfE3IJm2lbuWkR1aWIuWA/b69O88e/G0dEOFAlPfztrZVDG/Qw==", "dev": true, "dependencies": { "import-meta-resolve": "^4.0.0" @@ -2484,13 +2482,13 @@ } }, "node_modules/@cspell/eslint-plugin": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/@cspell/eslint-plugin/-/eslint-plugin-8.4.1.tgz", - "integrity": "sha512-C1U1iUr9WTzzSNzVbqQE6ktaYfQm6jjodGDvQIy+tBimsjInQaB39CnTzhkFEWKGZQVSIq8/RQ59Po0C8xrtgg==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/@cspell/eslint-plugin/-/eslint-plugin-8.5.0.tgz", + "integrity": "sha512-zmz1bwicW3wmLOmIw8cJXzDkEOGkU/htLY9a5vRYKugehetja6LMIWDEaBgK+9LJwfCOTXZ2kEbtVGyyt66aNw==", "dev": true, "dependencies": { - "@cspell/cspell-types": "8.4.1", - "cspell-lib": "8.4.1", + "@cspell/cspell-types": "8.5.0", + "cspell-lib": "8.5.0", "estree-walker": "^3.0.3", "synckit": "^0.9.0" }, @@ -2499,9 +2497,9 @@ } }, "node_modules/@cspell/strong-weak-map": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/@cspell/strong-weak-map/-/strong-weak-map-8.4.1.tgz", - "integrity": "sha512-TWIA9SrtQTvpT+RN1RJUA2OWH1qNbjsjby8EmHteHjrueFr4a9nRxl4etQ1EoiGaBwt2w1w1iatnfpRY0U15Zg==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/@cspell/strong-weak-map/-/strong-weak-map-8.5.0.tgz", + "integrity": "sha512-9pmhmYJVOUtO4G3mtSI0qjgxGQsz6rbFjm5dewolIEK+8rha3rcrlBqXy/h6RDgLVuBfA7kEcBZQ70wzEwETwA==", "dev": true, "engines": { "node": ">=18" @@ -7229,14 +7227,6 @@ "yarn": ">=1" } }, - "node_modules/cross-fetch": { - "version": "4.0.0", - "resolved": "https://registry.npmmirror.com/cross-fetch/-/cross-fetch-4.0.0.tgz", - "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", - "dependencies": { - "node-fetch": "^2.6.12" - } - }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmmirror.com/cross-spawn/-/cross-spawn-7.0.3.tgz", @@ -7286,14 +7276,14 @@ } }, "node_modules/cspell-config-lib": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/cspell-config-lib/-/cspell-config-lib-8.4.1.tgz", - "integrity": "sha512-Z1Krm0LBp+qe7jewRH6nxHzoeFgDCqlkihGDh09Q37JIlBzxzIv3FIG/RFZ9qw9B4waU00G+dCvWmec8j1y08Q==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/cspell-config-lib/-/cspell-config-lib-8.5.0.tgz", + "integrity": "sha512-J89uUFPANN4R+uwRh2WP4PYe9sVYbtKVzyJ53nPehv0RlJ+6XiQyqu6dnsT9rAjqHaAwf57iPBkMJiDir103eA==", "dev": true, "dependencies": { - "@cspell/cspell-types": "8.4.1", + "@cspell/cspell-types": "8.5.0", "comment-json": "^4.2.3", - "yaml": "^2.3.4" + "yaml": "^2.4.0" }, "engines": { "node": ">=18" @@ -7312,25 +7302,25 @@ } }, "node_modules/cspell-dictionary": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/cspell-dictionary/-/cspell-dictionary-8.4.1.tgz", - "integrity": "sha512-aN3Ei7MHQrG+EaAfBM3Y+w+KRuWTKxKsc2OYTEtgfLh6htxxdCzk/voA3OEHS8e+NXw2HMwrKmCPGGsKY9QkmA==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/cspell-dictionary/-/cspell-dictionary-8.5.0.tgz", + "integrity": "sha512-cr8wnSdfkNWtWsstZgTtvMNBns+pVHYMXwLWQ05VC6KyXfNW5zWNThrvzmaL9bLLXIUUOUkC2WWVa8bD20RcmQ==", "dev": true, "dependencies": { - "@cspell/cspell-pipe": "8.4.1", - "@cspell/cspell-types": "8.4.1", - "cspell-trie-lib": "8.4.1", + "@cspell/cspell-pipe": "8.5.0", + "@cspell/cspell-types": "8.5.0", + "cspell-trie-lib": "8.5.0", "fast-equals": "^5.0.1", - "gensequence": "^6.0.0" + "gensequence": "^7.0.0" }, "engines": { "node": ">=18" } }, "node_modules/cspell-glob": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/cspell-glob/-/cspell-glob-8.4.1.tgz", - "integrity": "sha512-W3kJPFpWO0L5XPMlJAiey0XfzdIG/bQFcQo2LgPX0ViGned2piH09F5aXpwSCfw2clGo4SWw0WYVOnTxMF89hg==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/cspell-glob/-/cspell-glob-8.5.0.tgz", + "integrity": "sha512-jvEGCwToql//WAAyoaOP+GtYAMyfjTkqOMSxZ0tMbj2T4TEC/xUH2/tTI8Xug3PDOr5a3J75inSzl9tC8ZVtWQ==", "dev": true, "dependencies": { "micromatch": "^4.0.5" @@ -7340,13 +7330,13 @@ } }, "node_modules/cspell-grammar": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/cspell-grammar/-/cspell-grammar-8.4.1.tgz", - "integrity": "sha512-JRbCuKWY5Ja39zmPUQPHM7WnnX4ODQo4kBNk4NJGnrADvHyor6Z60YPqy45IRnt/Z7B4U7J+T8M6bHlLFk3f2w==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/cspell-grammar/-/cspell-grammar-8.5.0.tgz", + "integrity": "sha512-29U4KFThztK9LBPrcdLJLld3uWIEAg8M5umfwrkDoGQA0jtdBe+4895rGuth4QcPxMT1jxn7cInv199Hx2R4XQ==", "dev": true, "dependencies": { - "@cspell/cspell-pipe": "8.4.1", - "@cspell/cspell-types": "8.4.1" + "@cspell/cspell-pipe": "8.5.0", + "@cspell/cspell-types": "8.5.0" }, "bin": { "cspell-grammar": "bin.mjs" @@ -7356,40 +7346,40 @@ } }, "node_modules/cspell-io": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/cspell-io/-/cspell-io-8.4.1.tgz", - "integrity": "sha512-FVOhg+rQP7YvX06t5to9oj83/COFnowW9J6ShY5Cp64s6yoQCTiPpTcKbHMiE4rwXpp5/FRAs86mr4jrR/zNUQ==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/cspell-io/-/cspell-io-8.5.0.tgz", + "integrity": "sha512-XiAhF/nX2M8xUX9OqXoGixePTmy7s0+Bfg07+nGTDKhLj0Ydpg/asxWVkd//YAX9kkpU3YukDon4Q4km95WgiA==", "dev": true, "dependencies": { - "@cspell/cspell-service-bus": "8.4.1" + "@cspell/cspell-service-bus": "8.5.0" }, "engines": { "node": ">=18" } }, "node_modules/cspell-lib": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/cspell-lib/-/cspell-lib-8.4.1.tgz", - "integrity": "sha512-R86NdkgyT4vCpBuNGd47WO9tNS2GQW8pGQZGdtqHcgf5gIl8U5tj4T0q0cQvR6WEsNTo+ElMf0GZ2TK3hXaZDg==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/cspell-lib/-/cspell-lib-8.5.0.tgz", + "integrity": "sha512-TSi2K8Xf7Ptti6EtSeG6A9kTaleMNwcayjXTBxsiCoVnW/bSTQ7cSzuO2JqT3wUK54XUu4HullTgoUv/tvqjCg==", "dev": true, "dependencies": { - "@cspell/cspell-bundled-dicts": "8.4.1", - "@cspell/cspell-pipe": "8.4.1", - "@cspell/cspell-resolver": "8.4.1", - "@cspell/cspell-types": "8.4.1", - "@cspell/dynamic-import": "8.4.1", - "@cspell/strong-weak-map": "8.4.1", + "@cspell/cspell-bundled-dicts": "8.5.0", + "@cspell/cspell-pipe": "8.5.0", + "@cspell/cspell-resolver": "8.5.0", + "@cspell/cspell-types": "8.5.0", + "@cspell/dynamic-import": "8.5.0", + "@cspell/strong-weak-map": "8.5.0", "clear-module": "^4.1.2", "comment-json": "^4.2.3", "configstore": "^6.0.0", - "cspell-config-lib": "8.4.1", - "cspell-dictionary": "8.4.1", - "cspell-glob": "8.4.1", - "cspell-grammar": "8.4.1", - "cspell-io": "8.4.1", - "cspell-trie-lib": "8.4.1", + "cspell-config-lib": "8.5.0", + "cspell-dictionary": "8.5.0", + "cspell-glob": "8.5.0", + "cspell-grammar": "8.5.0", + "cspell-io": "8.5.0", + "cspell-trie-lib": "8.5.0", "fast-equals": "^5.0.1", - "gensequence": "^6.0.0", + "gensequence": "^7.0.0", "import-fresh": "^3.3.0", "resolve-from": "^5.0.0", "vscode-languageserver-textdocument": "^1.0.11", @@ -7400,14 +7390,14 @@ } }, "node_modules/cspell-trie-lib": { - "version": "8.4.1", - "resolved": "https://registry.npmmirror.com/cspell-trie-lib/-/cspell-trie-lib-8.4.1.tgz", - "integrity": "sha512-qKPfHWsZlH1aZYMhScbWpdBn1xccQO++UZ4YgYikyNOJNyPS7SAgGvVgT8wE3f++dGfM77QKUwgLLfe6/udbHA==", + "version": "8.5.0", + "resolved": "https://registry.npmmirror.com/cspell-trie-lib/-/cspell-trie-lib-8.5.0.tgz", + "integrity": "sha512-RPKhJowuGpUc21GpREE9fdpds5JqdUmF1A/GXeFFzo1rwDiWA0Ojt60A72R90t2vygkAnD+kKtQkWX3LSoT3pQ==", "dev": true, "dependencies": { - "@cspell/cspell-pipe": "8.4.1", - "@cspell/cspell-types": "8.4.1", - "gensequence": "^6.0.0" + "@cspell/cspell-pipe": "8.5.0", + "@cspell/cspell-types": "8.5.0", + "gensequence": "^7.0.0" }, "engines": { "node": ">=18" @@ -7786,9 +7776,9 @@ "dev": true }, "node_modules/electron-to-chromium": { - "version": "1.4.689", - "resolved": "https://registry.npmmirror.com/electron-to-chromium/-/electron-to-chromium-1.4.689.tgz", - "integrity": "sha512-GatzRKnGPS1go29ep25reM94xxd1Wj8ritU0yRhCJ/tr1Bg8gKnm6R9O/yPOhGQBoLMZ9ezfrpghNaTw97C/PQ==", + "version": "1.4.690", + "resolved": "https://registry.npmmirror.com/electron-to-chromium/-/electron-to-chromium-1.4.690.tgz", + "integrity": "sha512-+2OAGjUx68xElQhydpcbqH50hE8Vs2K6TkAeLhICYfndb67CVH0UsZaijmRUE3rHlIxU1u0jxwhgVe6fK3YANA==", "dev": true }, "node_modules/emitter-listener": { @@ -10063,12 +10053,12 @@ } }, "node_modules/gensequence": { - "version": "6.0.0", - "resolved": "https://registry.npmmirror.com/gensequence/-/gensequence-6.0.0.tgz", - "integrity": "sha512-8WwuywE9pokJRAcg2QFR/plk3cVPebSUqRPzpGQh3WQ0wIiHAw+HyOQj5IuHyUTQBHpBKFoB2JUMu9zT3vJ16Q==", + "version": "7.0.0", + "resolved": "https://registry.npmmirror.com/gensequence/-/gensequence-7.0.0.tgz", + "integrity": "sha512-47Frx13aZh01afHJTB3zTtKIlFI6vWY+MYCN9Qpew6i52rfKjnhCF/l1YlC8UmEMvvntZZ6z4PiCcmyuedR2aQ==", "dev": true, "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/gensync": { @@ -10603,19 +10593,6 @@ "@babel/runtime": "^7.23.2" } }, - "node_modules/i18next-fs-backend": { - "version": "2.3.1", - "resolved": "https://registry.npmmirror.com/i18next-fs-backend/-/i18next-fs-backend-2.3.1.tgz", - "integrity": "sha512-tvfXskmG/9o+TJ5Fxu54sSO5OkY6d+uMn+K6JiUGLJrwxAVfer+8V3nU8jq3ts9Pe5lXJv4b1N7foIjJ8Iy2Gg==" - }, - "node_modules/i18next-http-backend": { - "version": "2.5.0", - "resolved": "https://registry.npmmirror.com/i18next-http-backend/-/i18next-http-backend-2.5.0.tgz", - "integrity": "sha512-Z/aQsGZk1gSxt2/DztXk92DuDD20J+rNudT7ZCdTrNOiK8uQppfvdjq9+DFQfpAnFPn3VZS+KQIr1S/W1KxhpQ==", - "dependencies": { - "cross-fetch": "4.0.0" - } - }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmmirror.com/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -13222,25 +13199,6 @@ "node": ">= 0.4.0" } }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmmirror.com/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/node-gyp-build": { "version": "4.8.0", "resolved": "https://registry.npmmirror.com/node-gyp-build/-/node-gyp-build-4.8.0.tgz", @@ -16847,11 +16805,6 @@ "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==", "dev": true }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmmirror.com/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" - }, "node_modules/trim-lines": { "version": "3.0.1", "resolved": "https://registry.npmmirror.com/trim-lines/-/trim-lines-3.0.1.tgz", @@ -18674,20 +18627,6 @@ "node": ">= 8" } }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmmirror.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" - }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmmirror.com/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/which": { "version": "3.0.1", "resolved": "https://registry.npmmirror.com/which/-/which-3.0.1.tgz", diff --git a/package.json b/package.json index c2957c0..7025503 100644 --- a/package.json +++ b/package.json @@ -56,8 +56,6 @@ "fs-extra": "latest", "i18next": "latest", "i18next-browser-languagedetector": "latest", - "i18next-fs-backend": "latest", - "i18next-http-backend": "latest", "isbot": "latest", "katex": "latest", "lodash": "latest", diff --git a/prisma/seed.ts b/prisma/seed.ts index b12e155..3d47087 100644 --- a/prisma/seed.ts +++ b/prisma/seed.ts @@ -85,7 +85,7 @@ await prisma.comment.create({ }); for (const lang of i18n.supportedLngs) { - const dir = join(cwd(), "articles", lang); + const dir = join(cwd(), "static", "articles", lang); for (const entry of await readdir(dir)) { await prisma.announcement.create({ diff --git a/articles/en/Insider Preview #46 Has Started.md b/static/articles/en/Insider Preview #46 Has Started.md similarity index 100% rename from articles/en/Insider Preview #46 Has Started.md rename to static/articles/en/Insider Preview #46 Has Started.md diff --git a/articles/en/Welcome to polygen.md b/static/articles/en/Welcome to polygen.md similarity index 100% rename from articles/en/Welcome to polygen.md rename to static/articles/en/Welcome to polygen.md diff --git "a/articles/zh/\346\254\242\350\277\216\346\235\245\345\210\260 polygen.md" "b/static/articles/zh/\346\254\242\350\277\216\346\235\245\345\210\260 polygen.md" similarity index 100% rename from "articles/zh/\346\254\242\350\277\216\346\235\245\345\210\260 polygen.md" rename to "static/articles/zh/\346\254\242\350\277\216\346\235\245\345\210\260 polygen.md" diff --git "a/articles/zh/\347\254\254 46 \346\254\241\345\206\205\346\265\213\345\267\262\345\274\200\345\247\213.md" "b/static/articles/zh/\347\254\254 46 \346\254\241\345\206\205\346\265\213\345\267\262\345\274\200\345\247\213.md" similarity index 100% rename from "articles/zh/\347\254\254 46 \346\254\241\345\206\205\346\265\213\345\267\262\345\274\200\345\247\213.md" rename to "static/articles/zh/\347\254\254 46 \346\254\241\345\206\205\346\265\213\345\267\262\345\274\200\345\247\213.md" diff --git a/public/locales/en/translation.json b/static/locales/en.json similarity index 100% rename from public/locales/en/translation.json rename to static/locales/en.json diff --git a/public/locales/zh/translation.json b/static/locales/zh.json similarity index 100% rename from public/locales/zh/translation.json rename to static/locales/zh.json diff --git a/public/favicon.ico b/static/public/favicon.ico similarity index 100% rename from public/favicon.ico rename to static/public/favicon.ico diff --git a/public/robots.txt b/static/public/robots.txt similarity index 100% rename from public/robots.txt rename to static/public/robots.txt diff --git a/vite.config.ts b/vite.config.ts index b6ec0ed..bd392b2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,10 +1,11 @@ import { vitePlugin as remix } from "@remix-run/dev"; -import { defineConfig } from "vite"; +import type { UserConfig } from "vite"; import tsconfigPaths from "vite-tsconfig-paths"; -export default defineConfig({ +export default { plugins: [remix(), tsconfigPaths()], build: { target: "ESNext" - } -}); + }, + publicDir: "static/public" +} satisfies UserConfig;