From bdc505bed663fff109c02f58cb86e64824991992 Mon Sep 17 00:00:00 2001 From: Merijn Hendriks Date: Mon, 15 Jan 2024 12:45:24 +0000 Subject: [PATCH] Add locales fallback (!197) Fixes [#310](https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/310) Co-authored-by: Merijn Hendriks Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/197 Co-authored-by: Merijn Hendriks Co-committed-by: Merijn Hendriks --- project/assets/database/locales/menu/ro.json | 28 -------------------- project/src/callbacks/DataCallbacks.ts | 26 +++++++++++++----- 2 files changed, 20 insertions(+), 34 deletions(-) delete mode 100644 project/assets/database/locales/menu/ro.json diff --git a/project/assets/database/locales/menu/ro.json b/project/assets/database/locales/menu/ro.json deleted file mode 100644 index 04f9d853..00000000 --- a/project/assets/database/locales/menu/ro.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "menu": { - "206 - Wrong email or password": "Wrong email or password", - "213 - Error connecting to auth server": "Authorization is unavailable now, please try again later.", - "240 - Servers temporarily unavailable. Please, try later.": "Server maintenance", - "ASSEMBLE": "ASSEMBLE", - "AUTHORIZATION": "AUTHORIZATION", - "BATTLEYE_ANTICHEAT_BadServiceVersion": "Bad service version", - "BATTLEYE_ANTICHEAT_ClientNotResponding": "Anticheat connection failed", - "BATTLEYE_ANTICHEAT_CorruptedData": "The integrity of the game failed to validate. Reinstall anticheat", - "BATTLEYE_ANTICHEAT_CorruptedMemory": "Corrupted memory. The integrity of the protection failed to validate. Reinstall anticheat", - "BATTLEYE_ANTICHEAT_DisallowedProgram": "Disallowed program running", - "BATTLEYE_ANTICHEAT_FailedToLoadAnticheat": "Anticheat loading failed.", - "BATTLEYE_ANTICHEAT_GameRestartRequired": "Game restart required", - "BATTLEYE_ANTICHEAT_GlobalBan": "The player has been banned by BE", - "BATTLEYE_ANTICHEAT_QueryTimeout": "Anticheat connection failed. Please restart the game", - "BATTLEYE_ANTICHEAT_WinAPIFailure": "A critical Windows API call failed", - "BATTLEYE_ServiceNeedsToBeUpdated": "Anticheat is outdated. Game restart required", - "BATTLEYE_ServiceNotRunningProperly": "Anticheat is running incorrectly. Game restart required", - "BATTLEYE_UnknownRestartReason": "Anticheat is running incorrectly. Game restart required", - "EXIT": "EXIT", - "NEXT": "NEXT", - "Place in queue:": "Place in queue:", - "Profile data loading...": "Loading profile data...", - "SABER_ANTICHEAT_AnticheatConnectionFailed": "Anticheat connection failed", - "Servers are currently at full capacity": "Servers are currently at full capacity" - } -} \ No newline at end of file diff --git a/project/src/callbacks/DataCallbacks.ts b/project/src/callbacks/DataCallbacks.ts index dd2d2f21..2b330356 100644 --- a/project/src/callbacks/DataCallbacks.ts +++ b/project/src/callbacks/DataCallbacks.ts @@ -151,9 +151,16 @@ export class DataCallbacks */ public getLocalesMenu(url: string, info: IEmptyRequestData, sessionID: string): IGetBodyResponseData { - return this.httpResponse.getBody( - this.databaseServer.getTables().locales.menu[url.replace("/client/menu/locale/", "")], - ); + const localeId = url.replace("/client/menu/locale/", ""); + const tables = this.databaseServer.getTables(); + let result = tables.locales.menu[localeId]; + + if (result === undefined) + { + result = tables.locales.menu["en"]; + } + + return this.httpResponse.getBody(result); } /** @@ -161,9 +168,16 @@ export class DataCallbacks */ public getLocalesGlobal(url: string, info: IEmptyRequestData, sessionID: string): string { - return this.httpResponse.getUnclearedBody( - this.databaseServer.getTables().locales.global[url.replace("/client/locale/", "")], - ); + const localeId = url.replace("/client/locale/", ""); + const tables = this.databaseServer.getTables(); + let result = tables.locales.global[localeId]; + + if (result === undefined) + { + result = tables.locales.global[localeId]; + } + + return this.httpResponse.getUnclearedBody(result); } /**