mirror of
https://gitlab.com/crafty-controller/crafty-4.git
synced 2024-08-30 18:23:09 +00:00
Merge branch 'lang/lang-names' into 'dev'
Add language header translations See merge request crafty-controller/crafty-4!773
This commit is contained in:
commit
a710c80bb2
@ -56,8 +56,8 @@ get_keys "${DIR}/en_EN.json" | sort > "${ref_keys}"
|
|||||||
|
|
||||||
# Iterate over each .json file in the directory
|
# Iterate over each .json file in the directory
|
||||||
for file in "${DIR}"/*.json; do
|
for file in "${DIR}"/*.json; do
|
||||||
# Check if file is a regular file and not en_EN.json, and does not contain "_incomplete" in its name
|
# Check if file is a regular file and not en_EN.json, humanized index and does not contain "_incomplete" in its name
|
||||||
if [[ -f "${file}" && "${file}" != "${DIR}/en_EN.json" && ! "${file}" =~ _incomplete ]]; then
|
if [[ -f "${file}" && "${file}" != "${DIR}/en_EN.json" && "${file}" != "${DIR}/humanized_index.json" && ! "${file}" =~ _incomplete ]]; then
|
||||||
|
|
||||||
# Get keys and subkeys from the current file
|
# Get keys and subkeys from the current file
|
||||||
current_keys=$(mktemp)
|
current_keys=$(mktemp)
|
||||||
|
@ -14,6 +14,7 @@ TBD
|
|||||||
- Add a thread dump to support logs ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/769))
|
- Add a thread dump to support logs ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/769))
|
||||||
- Remove text from status page and use symbols ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/770))
|
- Remove text from status page and use symbols ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/770))
|
||||||
### Lang
|
### Lang
|
||||||
|
- Show natural language name instead of country code in User Config Lang select list ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/773))
|
||||||
- Add remaining `he_IL`, `th_TH` translations for 4.4.0 Release ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/761))
|
- Add remaining `he_IL`, `th_TH` translations for 4.4.0 Release ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/761))
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class Translation:
|
|||||||
def get_language_file(self, language: str):
|
def get_language_file(self, language: str):
|
||||||
return os.path.join(self.translations_path, str(language) + ".json")
|
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"
|
fallback_language = "en_EN"
|
||||||
|
|
||||||
translated_word = self.translate_inner(page, word, language)
|
translated_word = self.translate_inner(page, word, language)
|
||||||
@ -37,7 +37,9 @@ class Translation:
|
|||||||
if hasattr(translated_word, "__iter__"):
|
if hasattr(translated_word, "__iter__"):
|
||||||
# Multiline strings
|
# Multiline strings
|
||||||
return "\n".join(translated_word)
|
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]:
|
def translate_inner(self, page, word, language) -> t.Union[t.Any, None]:
|
||||||
language_file = self.get_language_file(language)
|
language_file = self.get_language_file(language)
|
||||||
|
@ -892,6 +892,8 @@ class PanelHandler(BaseHandler):
|
|||||||
os.path.join(self.helper.root_dir, "app", "translations")
|
os.path.join(self.helper.root_dir, "app", "translations")
|
||||||
)
|
)
|
||||||
):
|
):
|
||||||
|
if file == "humanized_index.json":
|
||||||
|
continue
|
||||||
if file.endswith(".json"):
|
if file.endswith(".json"):
|
||||||
if file.split(".")[0] not in self.helper.get_setting(
|
if file.split(".")[0] not in self.helper.get_setting(
|
||||||
"disabled_language_files"
|
"disabled_language_files"
|
||||||
@ -1307,6 +1309,8 @@ class PanelHandler(BaseHandler):
|
|||||||
for file in sorted(
|
for file in sorted(
|
||||||
os.listdir(os.path.join(self.helper.root_dir, "app", "translations"))
|
os.listdir(os.path.join(self.helper.root_dir, "app", "translations"))
|
||||||
):
|
):
|
||||||
|
if file == "humanized_index.json":
|
||||||
|
continue
|
||||||
if file.endswith(".json"):
|
if file.endswith(".json"):
|
||||||
if file.split(".")[0] not in self.helper.get_setting(
|
if file.split(".")[0] not in self.helper.get_setting(
|
||||||
"disabled_language_files"
|
"disabled_language_files"
|
||||||
|
@ -122,7 +122,7 @@ data['lang']) }}{% end %}
|
|||||||
name="lang" form="user_form">
|
name="lang" form="user_form">
|
||||||
{% for lang in data['languages'] %}
|
{% for lang in data['languages'] %}
|
||||||
{% if not 'incomplete' in lang %}
|
{% if not 'incomplete' in lang %}
|
||||||
<option value="{{lang}}">{{lang}}</option>
|
<option value="{{lang}}" >{{translate('language', lang, 'humanized_index')}}</option>
|
||||||
{% else %}
|
{% else %}
|
||||||
<option value="{{lang}}" disabled>{{lang}}</option>
|
<option value="{{lang}}" disabled>{{lang}}</option>
|
||||||
{% end %}
|
{% end %}
|
||||||
|
19
app/translations/humanized_index.json
Normal file
19
app/translations/humanized_index.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"language": {
|
||||||
|
"cs_CS": "Čeština",
|
||||||
|
"de_DE": "Deutsch",
|
||||||
|
"en_EN": "English (US)",
|
||||||
|
"es_ES": "Español",
|
||||||
|
"fr_FR": "Français (France)",
|
||||||
|
"he_IL": "he_IL",
|
||||||
|
"it_IT": "Italiano",
|
||||||
|
"lol_EN": "Lolcatz",
|
||||||
|
"lv_LV": "Latviešu",
|
||||||
|
"nl_BE": "nl_BE",
|
||||||
|
"pl_PL": "Polski",
|
||||||
|
"th_TH": "ไทย",
|
||||||
|
"tr_TR": "Türkçe",
|
||||||
|
"uk_UA": "Українська",
|
||||||
|
"zh_CN": "中文(中国)"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user