diff --git a/src/controllers/custom/getItemListsController.ts b/src/controllers/custom/getItemListsController.ts index 8e360ca9..914bd5cc 100644 --- a/src/controllers/custom/getItemListsController.ts +++ b/src/controllers/custom/getItemListsController.ts @@ -1,5 +1,5 @@ import { RequestHandler } from "express"; -import { getEnglishString } from "@/src/services/itemDataService"; +import { getDict, getString } from "@/src/services/itemDataService"; import { ExportArcanes, ExportGear, @@ -16,7 +16,8 @@ interface ListedItem { fusionLimit?: number; } -const getItemListsController: RequestHandler = (_req, res) => { +const getItemListsController: RequestHandler = (req, res) => { + const lang = getDict(typeof req.query.lang == "string" ? req.query.lang : "en"); const weapons = []; const miscitems = []; for (const [uniqueName, item] of Object.entries(ExportWeapons)) { @@ -24,12 +25,12 @@ const getItemListsController: RequestHandler = (_req, res) => { if (item.totalDamage !== 0) { weapons.push({ uniqueName, - name: getEnglishString(item.name) + name: getString(item.name, lang) }); } else if (!item.excludeFromCodex) { miscitems.push({ uniqueName: "MiscItems:" + uniqueName, - name: getEnglishString(item.name) + name: getString(item.name, lang) }); } } @@ -37,13 +38,13 @@ const getItemListsController: RequestHandler = (_req, res) => { for (const [uniqueName, item] of Object.entries(ExportResources)) { miscitems.push({ uniqueName: item.productCategory + ":" + uniqueName, - name: getEnglishString(item.name) + name: getString(item.name, lang) }); } for (const [uniqueName, item] of Object.entries(ExportGear)) { miscitems.push({ uniqueName: "Consumables:" + uniqueName, - name: getEnglishString(item.name) + name: getString(item.name, lang) }); } @@ -52,7 +53,7 @@ const getItemListsController: RequestHandler = (_req, res) => { for (const [uniqueName, upgrade] of Object.entries(ExportUpgrades)) { mods.push({ uniqueName, - name: getEnglishString(upgrade.name), + name: getString(upgrade.name, lang), fusionLimit: upgrade.fusionLimit }); if (upgrade.isStarter || upgrade.isFrivolous || upgrade.upgradeEntries) { @@ -62,7 +63,7 @@ const getItemListsController: RequestHandler = (_req, res) => { for (const [uniqueName, arcane] of Object.entries(ExportArcanes)) { mods.push({ uniqueName, - name: getEnglishString(arcane.name) + name: getString(arcane.name, lang) }); if (arcane.isFrivolous) { badItems[uniqueName] = true; @@ -75,7 +76,7 @@ const getItemListsController: RequestHandler = (_req, res) => { .map(([uniqueName, warframe]) => { return { uniqueName, - name: getEnglishString(warframe.name) + name: getString(warframe.name, lang) }; }), weapons, diff --git a/src/services/itemDataService.ts b/src/services/itemDataService.ts index 33d7064b..ca9c0b0b 100644 --- a/src/services/itemDataService.ts +++ b/src/services/itemDataService.ts @@ -1,7 +1,21 @@ import { getIndexAfter } from "@/src/helpers/stringHelpers"; import { logger } from "@/src/utils/logger"; import { + dict_de, dict_en, + dict_es, + dict_fr, + dict_it, + dict_ja, + dict_ko, + dict_pl, + dict_pt, + dict_ru, + dict_tc, + dict_th, + dict_tr, + dict_uk, + dict_zh, ExportRecipes, ExportWarframes, ExportWeapons, @@ -70,6 +84,40 @@ export const getSuitByUniqueName = (uniqueName: string): IPowersuit | undefined return ExportWarframes[uniqueName]; }; -export const getEnglishString = (key: string): string => { - return dict_en[key] ?? key; +export const getDict = (lang: string): Record => { + switch (lang) { + case "de": + return dict_de; + case "es": + return dict_es; + case "fr": + return dict_fr; + case "it": + return dict_it; + case "ja": + return dict_ja; + case "ko": + return dict_ko; + case "pl": + return dict_pl; + case "pt": + return dict_pt; + case "ru": + return dict_ru; + case "tc": + return dict_tc; + case "th": + return dict_th; + case "tr": + return dict_tr; + case "uk": + return dict_uk; + case "zh": + return dict_zh; + } + return dict_en; +}; + +export const getString = (key: string, dict: Record): string => { + return dict[key] ?? key; }; diff --git a/static/webui/index.html b/static/webui/index.html index 983880c2..75a7ce0a 100644 --- a/static/webui/index.html +++ b/static/webui/index.html @@ -7,18 +7,40 @@ -