summary refs log tree commit diff
path: root/src/api/middlewares/Translation.ts
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-26 12:53:56 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-09-26 12:57:36 +1000
commit9c688527ec8fb6674ffd98b91c9b597ce3f10d9b (patch)
tree69b4eda441946c464ece1ca4e01d4f3fe54e95e9 /src/api/middlewares/Translation.ts
parentVscode launch config (diff)
downloadserver-9c688527ec8fb6674ffd98b91c9b597ce3f10d9b.tar.xz
Rearrange assets a bit, fix anything that uses assets folder
Diffstat (limited to 'src/api/middlewares/Translation.ts')
-rw-r--r--src/api/middlewares/Translation.ts8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/api/middlewares/Translation.ts b/src/api/middlewares/Translation.ts
index 741d6baf..c0b7a4b8 100644
--- a/src/api/middlewares/Translation.ts
+++ b/src/api/middlewares/Translation.ts
@@ -5,9 +5,11 @@ import i18nextMiddleware from "i18next-http-middleware";
 import i18nextBackend from "i18next-node-fs-backend";
 import { Router } from "express";
 
+const ASSET_FOLDER_PATH = path.join(__dirname, "..", "..", "..", "assets");
+
 export async function initTranslation(router: Router) {
-	const languages = fs.readdirSync(path.join(__dirname, "..", "..", "..", "assets", "locales"));
-	const namespaces = fs.readdirSync(path.join(__dirname, "..", "..", "..", "assets", "locales", "en"));
+	const languages = fs.readdirSync(path.join(ASSET_FOLDER_PATH, "locales"));
+	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));
 
 	await i18next
@@ -19,7 +21,7 @@ export async function initTranslation(router: Router) {
 			fallbackLng: "en",
 			ns,
 			backend: {
-				loadPath: __dirname + "/../../locales/{{lng}}/{{ns}}.json"
+				loadPath:  path.join(ASSET_FOLDER_PATH, "locales") + "/{{lng}}/{{ns}}.json",
 			},
 			load: "all"
 		});