Spaces:
Paused
Paused
rick
commited on
start the dream...
Browse files
scripts/gen_ui_lang_support.py
CHANGED
|
@@ -123,11 +123,29 @@ def generate_ui_lang_support(
|
|
| 123 |
return re.sub(r'^"{3}|"{3}$', '', response_text.strip())
|
| 124 |
|
| 125 |
openai_client = get_openai_connected_client()
|
| 126 |
-
|
|
|
|
| 127 |
for to_lang in target_ui_lang:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
PROMPT_ = get_prompt_translation_ui_text(base_ui_lang, to_lang)
|
| 129 |
traductions_ui_dict[to_lang] = {}
|
|
|
|
| 130 |
for key, text_ui in traductions_ui_dict[base_ui_lang].items():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
traduction_text_ui = create_chat_completion(openai_client, PROMPT_, text_ui)
|
| 132 |
traductions_ui_dict[to_lang][key] = traduction_text_ui
|
| 133 |
|
|
|
|
| 123 |
return re.sub(r'^"{3}|"{3}$', '', response_text.strip())
|
| 124 |
|
| 125 |
openai_client = get_openai_connected_client()
|
| 126 |
+
|
| 127 |
+
cnt=0
|
| 128 |
for to_lang in target_ui_lang:
|
| 129 |
+
cnt += 1
|
| 130 |
+
# print a progression message: f"[{cnt}/{len(target_ui_lang)}] Translating UI text to {to_lang}..."
|
| 131 |
+
# Colors like an hacker terminal, because it's cool !
|
| 132 |
+
# {cnt} and {len(target_ui_lang)} are the current and total number of languages to translate , respectively in yellow FG and green FG.
|
| 133 |
+
# '[' ']' are white FG
|
| 134 |
+
# {to_lang} is the language to translate in cyan FG
|
| 135 |
+
# "Translating UI text to" is in light green FG
|
| 136 |
+
print(f"\033[93m[{cnt}/{len(target_ui_lang)}]\033[0m \033[92mTranslating UI text to \033[0m\033[96m{to_lang}...\033[0m")
|
| 137 |
PROMPT_ = get_prompt_translation_ui_text(base_ui_lang, to_lang)
|
| 138 |
traductions_ui_dict[to_lang] = {}
|
| 139 |
+
it_cnt=0
|
| 140 |
for key, text_ui in traductions_ui_dict[base_ui_lang].items():
|
| 141 |
+
it_cnt += 1
|
| 142 |
+
# print a progression message: f" [{it_cnt}/{len(traductions_ui_dict[base_ui_lang].keys())}] + Translating UI text value of key '{key}'..."
|
| 143 |
+
# Colors like an hacker terminal, because it's cool !
|
| 144 |
+
# {it_cnt} and {len(traductions_ui_dict[base_ui_lang].keys())} are the current and total number of UI text values to translate , respectively in yellow FG and green FG.
|
| 145 |
+
# '[' ']' are white FG
|
| 146 |
+
# {key} is the key of the UI text value to translate in cyan FG
|
| 147 |
+
# "Translating UI text value of key" is in light green FG
|
| 148 |
+
print(f" \033[93m[{it_cnt}/{len(traductions_ui_dict[base_ui_lang].keys())}]\033[0m \033[92mTranslating UI text value of key \033[0m\033[96m'{key}'...\033[0m")
|
| 149 |
traduction_text_ui = create_chat_completion(openai_client, PROMPT_, text_ui)
|
| 150 |
traductions_ui_dict[to_lang][key] = traduction_text_ui
|
| 151 |
|