Add language header translations

This commit is contained in:
amcmanu3 2024-06-22 18:44:02 -04:00
parent 2a6c0ca751
commit e33cf5451c
3 changed files with 23 additions and 4 deletions

View File

@ -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)

View File

@ -122,7 +122,7 @@ data['lang']) }}{% end %}
name="lang" form="user_form">
{% for lang in data['languages'] %}
{% if not 'incomplete' in lang %}
<option value="{{lang}}">{{lang}}</option>
<option value="{{lang}}" >{{translate('language', lang, data['lang'], False)}}</option>
{% else %}
<option value="{{lang}}" disabled>{{lang}}</option>
{% end %}

View File

@ -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"
}
}
}