Closes #2223 - [x] Adds `localesAvailable` to `/api/settings` endpoint, and uses that list if available, rather than the full list of translated locales, to determine which options to display to users - [x] ~~Uses the user's browser locales, filtered to the current language setting, for formatting numbers, dates, and durations~~ - [x] Adds & persists checkbox for "use same language for formatting dates and numbers" in user settings - [x] Replaces uses of `sl-format-bytes` with `localize.bytes(...)`, and `sl-format-date` with replacement `btrix-format-date` that properly handles fallback locales - [x] Caches all number/duration/datetime formatters by a combined key consisting of app language, browser language, browser setting, and formatter options so that all formatters can be reused if needed (previously any formatter with non-default options would be recreated every render) - [x] Splits out ordinal formatting from number formatter, as it didn't make much sense in some non-English locales - [x] Adds a little demo of date/time/duration/number formatting so you can see what effect your language settings have https://github.com/user-attachments/assets/724858cb-b140-4d72-a38d-83f602c71bc7 --------- Signed-off-by: emma <hi@emma.cafe> Co-authored-by: Ilya Kreymer <ikreymer@gmail.com> Co-authored-by: Ilya Kreymer <ikreymer@users.noreply.github.com>
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
// Serve app locally without building with webpack, e.g. for e2e
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
|
|
const express = require("express");
|
|
const { createProxyMiddleware } = require("http-proxy-middleware");
|
|
|
|
const distPath = path.join(process.cwd(), "dist");
|
|
if (!fs.existsSync(path.join(distPath, "index.html"))) {
|
|
throw new Error("dist folder is missing");
|
|
}
|
|
|
|
const dotEnvPath = path.resolve(process.cwd(), ".env.local");
|
|
require("dotenv").config({
|
|
path: dotEnvPath,
|
|
});
|
|
|
|
const [devConfig] = require("../webpack.dev.js");
|
|
|
|
const app = express();
|
|
|
|
const { devServer } = devConfig;
|
|
|
|
devServer.setupMiddlewares([], { app });
|
|
|
|
Object.keys(devServer.proxy).forEach((path) => {
|
|
app.use(
|
|
path,
|
|
createProxyMiddleware({
|
|
target: devServer.proxy[path],
|
|
changeOrigin: true,
|
|
}),
|
|
);
|
|
});
|
|
app.use("/", express.static(distPath));
|
|
app.get("/*", (req, res) => {
|
|
res.sendFile(path.join(distPath, "index.html"));
|
|
});
|
|
|
|
app.listen(9871, () => {
|
|
console.log("Server listening on http://localhost:9871");
|
|
});
|