From 572d7989d853c95382294d7a281cfb27712979dd Mon Sep 17 00:00:00 2001 From: HU Xin Date: Fri, 13 Sep 2024 14:14:20 +0200 Subject: [PATCH] feat:Gemini translation improved --- .github/workflows/translate.yml | 2 +- assets/flutter_i18n/en.json | 2 +- assets/flutter_i18n/translate.py | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/translate.yml b/.github/workflows/translate.yml index 681f4b32..4d1c19e9 100644 --- a/.github/workflows/translate.yml +++ b/.github/workflows/translate.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.9' # Specify Python version + python-version: '3.12.3' # Specify Python version - name: Install dependencies run: | diff --git a/assets/flutter_i18n/en.json b/assets/flutter_i18n/en.json index d6105541..edf561f9 100644 --- a/assets/flutter_i18n/en.json +++ b/assets/flutter_i18n/en.json @@ -453,7 +453,7 @@ "you_will_be_directed_to_the_main_app": "You will be directed to the main app", "account_setup_complete": "Account Setup Complete!", "entering_the_app": "Entering the App", - "in": "Loading..", + "in": "Loading...", "google_drive_secured_storage": "Google Drive secured storage", "icloud_secured_storage": "iCloud Secured storage", "make_sure_you_have_stored_your_keys_correctly_in_your_x": "Make sure you have stored your keys correctly in your {0}", diff --git a/assets/flutter_i18n/translate.py b/assets/flutter_i18n/translate.py index 5eff2329..5dd7cde1 100644 --- a/assets/flutter_i18n/translate.py +++ b/assets/flutter_i18n/translate.py @@ -12,9 +12,7 @@ def translate(text, target_language): response = model.generate_content( [f"this is an API, please just translate the following English text to {target_language}: {text}"] ) - # Extract the translated text - translated_text = response.result.candidates[0].content.parts[0].text.strip() - return translated_text + return response.text.strip() def main(): language_dict = {