mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Add language header translations
This commit is contained in:
parent
2a6c0ca751
commit
e33cf5451c
@ -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)
|
||||
|
@ -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 %}
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user