Rearrange assets a bit, fix anything that uses assets folder
This commit is contained in:
parent
8351415d15
commit
9c688527ec
Before Width: | Height: | Size: 312 KiB After Width: | Height: | Size: 312 KiB |
@ -5,9 +5,11 @@ import i18nextMiddleware from "i18next-http-middleware";
|
|||||||
import i18nextBackend from "i18next-node-fs-backend";
|
import i18nextBackend from "i18next-node-fs-backend";
|
||||||
import { Router } from "express";
|
import { Router } from "express";
|
||||||
|
|
||||||
|
const ASSET_FOLDER_PATH = path.join(__dirname, "..", "..", "..", "assets");
|
||||||
|
|
||||||
export async function initTranslation(router: Router) {
|
export async function initTranslation(router: Router) {
|
||||||
const languages = fs.readdirSync(path.join(__dirname, "..", "..", "..", "assets", "locales"));
|
const languages = fs.readdirSync(path.join(ASSET_FOLDER_PATH, "locales"));
|
||||||
const namespaces = fs.readdirSync(path.join(__dirname, "..", "..", "..", "assets", "locales", "en"));
|
const namespaces = fs.readdirSync(path.join(ASSET_FOLDER_PATH, "locales", "en"));
|
||||||
const ns = namespaces.filter((x) => x.endsWith(".json")).map((x) => x.slice(0, x.length - 5));
|
const ns = namespaces.filter((x) => x.endsWith(".json")).map((x) => x.slice(0, x.length - 5));
|
||||||
|
|
||||||
await i18next
|
await i18next
|
||||||
@ -19,7 +21,7 @@ export async function initTranslation(router: Router) {
|
|||||||
fallbackLng: "en",
|
fallbackLng: "en",
|
||||||
ns,
|
ns,
|
||||||
backend: {
|
backend: {
|
||||||
loadPath: __dirname + "/../../locales/{{lng}}/{{ns}}.json"
|
loadPath: path.join(ASSET_FOLDER_PATH, "locales") + "/{{lng}}/{{ns}}.json",
|
||||||
},
|
},
|
||||||
load: "all"
|
load: "all"
|
||||||
});
|
});
|
||||||
|
@ -34,7 +34,7 @@ router.get("/", route({}), async (req: Request, res: Response) => {
|
|||||||
const sizeOf = require("image-size");
|
const sizeOf = require("image-size");
|
||||||
|
|
||||||
// TODO: Widget style templates need Fosscord branding
|
// TODO: Widget style templates need Fosscord branding
|
||||||
const source = path.join(__dirname, "..", "..", "..", "..", "assets", "widget", `${style}.png`);
|
const source = path.join(__dirname, "..", "..", "..", "..", "..", "assets", "widget", `${style}.png`);
|
||||||
if (!fs.existsSync(source)) {
|
if (!fs.existsSync(source)) {
|
||||||
throw new HTTPError("Widget template does not exist.", 400);
|
throw new HTTPError("Widget template does not exist.", 400);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user