From e33cf5451c37dad118d8b0ba5dcafdd9a550c685 Mon Sep 17 00:00:00 2001 From: amcmanu3 Date: Sat, 22 Jun 2024 18:44:02 -0400 Subject: [PATCH] Add language header translations --- app/classes/shared/translation.py | 6 ++++-- .../templates/panel/panel_edit_user.html | 2 +- app/translations/en_EN.json | 19 ++++++++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/app/classes/shared/translation.py b/app/classes/shared/translation.py index 0e441808..538856a8 100644 --- a/app/classes/shared/translation.py +++ b/app/classes/shared/translation.py @@ -20,7 +20,7 @@ class Translation: def get_language_file(self, language: str): return os.path.join(self.translations_path, str(language) + ".json") - def translate(self, page, word, language): + def translate(self, page, word, language, error=True): fallback_language = "en_EN" translated_word = self.translate_inner(page, word, language) @@ -37,7 +37,9 @@ class Translation: if hasattr(translated_word, "__iter__"): # Multiline strings return "\n".join(translated_word) - return "Error while getting translation" + if error: + return "Error while getting translation" + return word def translate_inner(self, page, word, language) -> t.Union[t.Any, None]: language_file = self.get_language_file(language) diff --git a/app/frontend/templates/panel/panel_edit_user.html b/app/frontend/templates/panel/panel_edit_user.html index 87631219..e42f243f 100644 --- a/app/frontend/templates/panel/panel_edit_user.html +++ b/app/frontend/templates/panel/panel_edit_user.html @@ -122,7 +122,7 @@ data['lang']) }}{% end %} name="lang" form="user_form"> {% for lang in data['languages'] %} {% if not 'incomplete' in lang %} - + {% else %} {% end %} diff --git a/app/translations/en_EN.json b/app/translations/en_EN.json index 38d1fc74..e0e96b07 100644 --- a/app/translations/en_EN.json +++ b/app/translations/en_EN.json @@ -217,6 +217,23 @@ "copyright": "Copyright", "version": "Version" }, + "language": { + "cs_CS": "cs_CS", + "de_DE": "de_DE", + "en_EN": "English", + "es_ES": "es_ES", + "fr_FR": "fr_FR", + "he_IL": "he_IL", + "it_IT": "it_IT", + "lol_EN": "lol_EN", + "lv_LV": "lv_LV", + "nl_BE": "nl_BE", + "pl_PL": "pl_PL", + "th_TH": "th_TH", + "tr_TR": "tr_TR", + "uk_UA": "uk_UA", + "zh_CN": "zh_CN" + }, "login": { "defaultPath": "The password you entered is the default credential path, not the password. Please find the default password in that location.", "disabled": "User account disabled. Please contact your system administrator for more info.", @@ -675,4 +692,4 @@ "webhook_body": "Webhook Body", "webhooks": "Webhooks" } -} +} \ No newline at end of file