Spaces:
Paused
Paused
rick
commited on
fix errors...
Browse files
scripts/gen_ui_lang_support.py
CHANGED
|
@@ -94,8 +94,6 @@ def generate_ui_lang_support(
|
|
| 94 |
])
|
| 95 |
return prompt_
|
| 96 |
|
| 97 |
-
|
| 98 |
-
|
| 99 |
def get_openai_connected_client():
|
| 100 |
openai_client = OpenAI(api_key=getenv("OPENAI_API_KEY"))
|
| 101 |
return openai_client
|
|
@@ -103,7 +101,7 @@ def generate_ui_lang_support(
|
|
| 103 |
def create_chat_completion(client,
|
| 104 |
system_prompt,
|
| 105 |
user_input,
|
| 106 |
-
model="gpt-4o",
|
| 107 |
temperature=0.01,):
|
| 108 |
response = client.chat.completions.create(
|
| 109 |
model=f"{model}",
|
|
@@ -149,7 +147,14 @@ def generate_ui_lang_support(
|
|
| 149 |
# {key} is the key of the UI text value to translate in cyan FG
|
| 150 |
# "Translating UI text value of key" is in light green FG
|
| 151 |
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")
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
traductions_ui_dict[to_lang][key] = traduction_text_ui
|
| 154 |
|
| 155 |
return json.dumps(traductions_ui_dict, indent=4, ensure_ascii=False, sort_keys=False)
|
|
@@ -159,7 +164,7 @@ def generate_ui_lang_support(
|
|
| 159 |
if __name__ == "__main__":
|
| 160 |
JSON_UI_LANG_SUPPORT = generate_ui_lang_support(
|
| 161 |
base_ui_lang="Français",
|
| 162 |
-
target_ui_lang=SUPPORTED_LANGUAGES_FR_
|
| 163 |
)
|
| 164 |
|
| 165 |
# encoding , fr_FR.UTF-8
|
|
|
|
| 94 |
])
|
| 95 |
return prompt_
|
| 96 |
|
|
|
|
|
|
|
| 97 |
def get_openai_connected_client():
|
| 98 |
openai_client = OpenAI(api_key=getenv("OPENAI_API_KEY"))
|
| 99 |
return openai_client
|
|
|
|
| 101 |
def create_chat_completion(client,
|
| 102 |
system_prompt,
|
| 103 |
user_input,
|
| 104 |
+
model="gpt-4o-mini",
|
| 105 |
temperature=0.01,):
|
| 106 |
response = client.chat.completions.create(
|
| 107 |
model=f"{model}",
|
|
|
|
| 147 |
# {key} is the key of the UI text value to translate in cyan FG
|
| 148 |
# "Translating UI text value of key" is in light green FG
|
| 149 |
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")
|
| 150 |
+
operation_prompt = f"Translate(\'{base_ui_lang}\' to \'{to_lang}\')"
|
| 151 |
+
traduction_text_ui = remove_response_separator(
|
| 152 |
+
create_chat_completion(
|
| 153 |
+
openai_client,
|
| 154 |
+
PROMPT_,
|
| 155 |
+
f'{operation_prompt} :\n\"\"\"\n{text_ui}\n\"\"\"'
|
| 156 |
+
)
|
| 157 |
+
).strip()
|
| 158 |
traductions_ui_dict[to_lang][key] = traduction_text_ui
|
| 159 |
|
| 160 |
return json.dumps(traductions_ui_dict, indent=4, ensure_ascii=False, sort_keys=False)
|
|
|
|
| 164 |
if __name__ == "__main__":
|
| 165 |
JSON_UI_LANG_SUPPORT = generate_ui_lang_support(
|
| 166 |
base_ui_lang="Français",
|
| 167 |
+
target_ui_lang=LANG__ #SUPPORTED_LANGUAGES_FR_
|
| 168 |
)
|
| 169 |
|
| 170 |
# encoding , fr_FR.UTF-8
|