Procházet zdrojové kódy

fix: add language env

C4illin před 1 měsícem
rodič
revize
f789d9dfe3
3 změnil soubory, kde provedl 15 přidání a 12 odebrání
  1. 11 10
      README.md
  2. 2 0
      src/helpers/env.ts
  3. 2 2
      src/pages/history.tsx

+ 11 - 10
README.md

@@ -80,16 +80,17 @@ If you get unable to open database file run `chown -R $USER:$USER path` on the p
 
 All are optional, JWT_SECRET is recommended to be set.
 
-| Name                      | Default                                            | Description                                                                                              |
-| ------------------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
-| JWT_SECRET                | when unset it will use the value from randomUUID() | A long and secret string used to sign the JSON Web Token                                                 |
-| ACCOUNT_REGISTRATION      | false                                              | Allow users to register accounts                                                                         |
-| HTTP_ALLOWED              | false                                              | Allow HTTP connections, only set this to true locally                                                    |
-| ALLOW_UNAUTHENTICATED     | false                                              | Allow unauthenticated users to use the service, only set this to true locally                            |
-| AUTO_DELETE_EVERY_N_HOURS | 24                                                 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable                  |
-| WEBROOT                   |                                                    | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/" |
-| FFMPEG_ARGS               |                                                    | Arguments to pass to ffmpeg, e.g. `-preset veryfast`                                                     |
-| HIDE_HISTORY              | false                                              | Hide the history page                                                                                    |
+| Name                      | Default                                            | Description                                                                                                               |
+| ------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
+| JWT_SECRET                | when unset it will use the value from randomUUID() | A long and secret string used to sign the JSON Web Token                                                                  |
+| ACCOUNT_REGISTRATION      | false                                              | Allow users to register accounts                                                                                          |
+| HTTP_ALLOWED              | false                                              | Allow HTTP connections, only set this to true locally                                                                     |
+| ALLOW_UNAUTHENTICATED     | false                                              | Allow unauthenticated users to use the service, only set this to true locally                                             |
+| AUTO_DELETE_EVERY_N_HOURS | 24                                                 | Checks every n hours for files older then n hours and deletes them, set to 0 to disable                                   |
+| WEBROOT                   |                                                    | The address to the root path setting this to "/convert" will serve the website on "example.com/convert/"                  |
+| FFMPEG_ARGS               |                                                    | Arguments to pass to ffmpeg, e.g. `-preset veryfast`                                                                      |
+| HIDE_HISTORY              | false                                              | Hide the history page                                                                                                     |
+| LANGUAGE                  | en                                                 | Language to format date strings in, specified as a [BCP 47 language tag](https://en.wikipedia.org/wiki/IETF_language_tag) |
 
 ### Docker images
 

+ 2 - 0
src/helpers/env.ts

@@ -13,3 +13,5 @@ export const AUTO_DELETE_EVERY_N_HOURS = process.env.AUTO_DELETE_EVERY_N_HOURS
 export const HIDE_HISTORY = process.env.HIDE_HISTORY?.toLowerCase() === "true" || false;
 
 export const WEBROOT = process.env.WEBROOT ?? "";
+
+export const LANGUAGE = process.env.LANGUAGE?.toLowerCase() || "en";

+ 2 - 2
src/pages/history.tsx

@@ -4,7 +4,7 @@ import { BaseHtml } from "../components/base";
 import { Header } from "../components/header";
 import db from "../db/db";
 import { Filename, Jobs } from "../db/types";
-import { ALLOW_UNAUTHENTICATED, HIDE_HISTORY, WEBROOT } from "../helpers/env";
+import { ALLOW_UNAUTHENTICATED, HIDE_HISTORY, LANGUAGE, WEBROOT } from "../helpers/env";
 import { userService } from "./user";
 
 export const history = new Elysia()
@@ -133,7 +133,7 @@ export const history = new Elysia()
                             />
                           </svg>
                         </td>
-                        <td safe>{new Date(job.date_created).toLocaleTimeString()}</td>
+                        <td safe>{new Date(job.date_created).toLocaleTimeString(LANGUAGE)}</td>
                         <td>{job.num_files}</td>
                         <td class="max-sm:hidden">{job.finished_files}</td>
                         <td safe>{job.status}</td>