From 089e6b086c7b125ef077a9351f50c292c8cbd712 Mon Sep 17 00:00:00 2001 From: Marco Rodolfi Date: Thu, 4 May 2023 17:46:00 +0200 Subject: Small fix: handle missing localization in backend plus a small typo in the english language (#443) * Hotfix for i18n where the detector was overriding localStorage * Please, pnpm, cooperate * Small fix regarding the backend getting hammered when switching to not supported languages plus a small english typo --- backend/loader.py | 10 +++++++--- backend/locales/en-US.json | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'backend') diff --git a/backend/loader.py b/backend/loader.py index 8c4c4a7f..d8b97bbd 100644 --- a/backend/loader.py +++ b/backend/loader.py @@ -101,9 +101,13 @@ class Loader: return web.FileResponse(file, headers={"Cache-Control": "no-cache"}) async def handle_frontend_locales(self, request): - file = path.join(path.dirname(__file__), "locales", request.match_info["path"]) - - return web.FileResponse(file, headers={"Cache-Control": "no-cache", "Content-Type": "application/json"}) + req_lang = request.match_info["path"] + file = path.join(path.dirname(__file__), "locales", req_lang) + if exists(file): + return web.FileResponse(file, headers={"Cache-Control": "no-cache", "Content-Type": "application/json"}) + else: + self.logger.info(f"Language {req_lang} not available, returning an empty dictionary") + return web.json_response(data={}, headers={"Cache-Control": "no-cache"}) async def get_plugins(self, request): plugins = list(self.plugins.values()) diff --git a/backend/locales/en-US.json b/backend/locales/en-US.json index 70a7a7ae..4abac003 100644 --- a/backend/locales/en-US.json +++ b/backend/locales/en-US.json @@ -171,7 +171,7 @@ "patch_notes_desc": "Patch Notes", "updates": { "check_button": "Check For Updates", - "checking": "'Checking", + "checking": "Checking", "cur_version": "Current version: {{ver}}", "install_button": "Install Update", "label": "Updates", -- cgit v1.2.3