From c20d807d5ca2d17c1236af94c2ae9bb6131e02c0 Mon Sep 17 00:00:00 2001 From: rexwzh <1073853456@qq.com> Date: Thu, 11 Jul 2024 01:26:06 +0800 Subject: [PATCH] add default language configuration --- client/src/state/preferences.ts | 4 ++-- doc/npm_scripts.md | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/client/src/state/preferences.ts b/client/src/state/preferences.ts index 327af682..e58268f9 100644 --- a/client/src/state/preferences.ts +++ b/client/src/state/preferences.ts @@ -18,8 +18,8 @@ export const AUTO_SWITCH_THRESHOLD = 800 const initialState: PreferencesState = loadPreferences() ??{ layout: "auto", isSavePreferences: false, - language: "en", -} + language: import.meta.env.VITE_CLIENT_DEFAULT_LANGUAGE || "en", +}; export const preferencesSlice = createSlice({ name: "preferences", diff --git a/doc/npm_scripts.md b/doc/npm_scripts.md index cf800708..389917f1 100644 --- a/doc/npm_scripts.md +++ b/doc/npm_scripts.md @@ -7,3 +7,13 @@ Internally, websocket requests to `ws://localhost:3000/websockets` will be forwa On the server side, the command will set up a docker image containing the Lean server. The two parts can be built separately using `npm run build_client` and `npm run build_server`. * `npm run production`: Start the project in production mode. This requires that the build script has been run. It will start a server on the port specified in the `PORT` environment variable or by default on `8080`. You can run on a specific port by running `PORT=80 npm run production`. The server will serve the files in `client/dist` via http and give access to the bubblewrapped Lean server via the web socket protocol. + +### Environment Variables + +The client and server ports, as well as the default language, can be configured using environment variables: + +* `PORT`: Sets the port for the backend server (default: `8080`). +* `CLIENT_PORT`: Sets the port for the client server (default: `3000`). +* `VITE_CLIENT_DEFAULT_LANGUAGE`: Sets the default language for the application (default: `en`). + +Ensure these environment variables are set appropriately in your environment to configure the project as needed.