From a897edc84f1790ee4c58f27676c7afb6c6f3610c Mon Sep 17 00:00:00 2001 From: yunshu Date: Fri, 18 Jul 2025 21:49:36 +0800 Subject: [PATCH] Add French language support and update docs Introduces French (fr) as a supported language across the workflow, installation script, translation utility, and documentation. Updates language selection menus, README files, and adds a new French README. Also bumps shell_version to 2.6.1 and improves language selection logic. Update translate.py Update translate.py Update README instructions and links in EN/FR Added a link to the background story of 'idleleo' in both English and French README files. Updated the Simplified Chinese link in the French README and replaced the Telegram group link with a clickable version. Update README.md Update Backstory links in README translations Changed the 'idleleo' background story links in the main and translated README files to point to specific anchor sections for improved navigation. --- .github/workflows/i18n.yml | 10 ++-- README.md | 4 +- install.sh | 20 ++++--- languages/en/README.md | 4 +- languages/fa/README.md | 4 +- languages/fr/README.md | 105 +++++++++++++++++++++++++++++++++++++ languages/ko/README.md | 4 +- languages/ru/README.md | 4 +- translate.py | 29 ++++------ 9 files changed, 144 insertions(+), 40 deletions(-) create mode 100644 languages/fr/README.md diff --git a/.github/workflows/i18n.yml b/.github/workflows/i18n.yml index 02a7a88..08f910d 100644 --- a/.github/workflows/i18n.yml +++ b/.github/workflows/i18n.yml @@ -55,7 +55,7 @@ jobs: - name: Setup directories run: | mkdir -p po - mkdir -p languages/{en,fa,ru,zh_CN,ko}/LC_MESSAGES + mkdir -p languages/{en,fa,ru,zh_CN,ko,fr}/LC_MESSAGES - name: Extract strings from specified scripts run: | @@ -77,7 +77,7 @@ jobs: - name: Update/Create PO files run: | rm -f po/*.po - for lang in zh_CN en fa ru ko; do + for lang in zh_CN en fa ru ko fr; do msginit --no-translator --locale=$lang --input=po/xray_install.pot --output=po/$lang.po done @@ -89,7 +89,7 @@ jobs: - name: Compile MO files if necessary run: | needs_compile=false - for lang in en fa ru ko; do + for lang in en fa ru ko fr; do if [ ! -f "po/${lang}.po.no-update" ]; then needs_compile=true if ! msgfmt --check -v --statistics -o languages/${lang}/LC_MESSAGES/xray_install.mo po/${lang}.po; then @@ -108,7 +108,7 @@ jobs: - name: Run i18nspector checks on MO files if compiled run: | - for lang in en fa ru ko; do + for lang in en fa ru ko fr; do if [ ! -f "po/${lang}.po.no-update" ] && [ -f "languages/${lang}/LC_MESSAGES/xray_install.mo" ]; then i18nspector check-binary languages/${lang}/LC_MESSAGES/xray_install.mo fi @@ -128,7 +128,7 @@ jobs: - name: Commit changes if necessary run: | needs_commit=false - for lang in en fa ru ko; do + for lang in en fa ru ko fr; do if [ ! -f "po/${lang}.po.no-update" ]; then needs_commit=true break diff --git a/README.md b/README.md index 7d4dcaf..c595e68 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Xray 支持 Reality / VLESS WebSocket/gRPC+TLS 协议 + Nginx 的一键安装脚本 -简体中文 | [English](/languages/en/README.md) | [Русский](/languages/ru/README.md) | [فارسی](/languages/fa/README.md) | [한국어](/languages/ko/README.md) +简体中文 | [English](/languages/en/README.md) | [Français](/languages/fr/README.md) | [Русский](/languages/ru/README.md) | [فارسی](/languages/fa/README.md) | [한국어](/languages/ko/README.md) [![GitHub stars](https://img.shields.io/github/stars/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/stargazers) [![GitHub forks](https://img.shields.io/github/forks/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/network) [![GitHub issues](https://img.shields.io/github/issues/hello-yunshu/Xray_bash_onekey)](https://github.com/hello-yunshu/Xray_bash_onekey/issues) @@ -8,7 +8,7 @@ ## 使用说明 -* 可以直接输入命令:`idleleo` 管理脚本。 +* 可以直接输入命令:`idleleo` 管理脚本。 ( [查看 `idleleo` 背景故事](https://github.com/hello-yunshu/Xray_bash_onekey/wiki/Backstory#%E9%80%8D%E9%81%A5%E4%BB%99%E9%80%94idleleo-%E4%B9%8B%E5%90%8D) ) * 使用 DeepSeek AI 实现多国语言精准翻译。 * Reality 建议使用 Nginx 前置,在脚本中安装即可。 * 建议开启 fail2ban ,在脚本中安装即可。 diff --git a/install.sh b/install.sh index adc6601..cea4693 100644 --- a/install.sh +++ b/install.sh @@ -35,7 +35,7 @@ OK="${Green}[OK]${Font}" Error="${RedW}[$(gettext "错误")]${Font}" Warning="${RedW}[$(gettext "警告")]${Font}" -shell_version="2.6.0" +shell_version="2.6.1" shell_mode="$(gettext "未安装")" tls_mode="None" ws_grpc_mode="None" @@ -277,6 +277,7 @@ init_language() { "fa_IR") lang_code="fa" ;; "ru_RU") lang_code="ru" ;; "ko_KR") lang_code="ko" ;; + "fr_FR") lang_code="fr" ;; *) log_echo "${Warning} ${YellowBG} $(gettext "不支持的语言"):${LANG%.*}, $(gettext "将使用默认语言") ${Font}" export LANG=zh_CN.UTF-8 @@ -3581,12 +3582,13 @@ set_language() { log_echo "${GreenBG} 选择语言 / Select Language / انتخاب زبان / Выберите язык ${Font}" echo -e "${Green}1.${Font} 中文" echo -e "${Green}2.${Font} English" - echo -e "${Green}3.${Font} فارسی" - echo -e "${Green}4.${Font} Русский" - echo -e "${Green}5.${Font} 한국어" + echo -e "${Green}3.${Font} Français" + echo -e "${Green}4.${Font} فارسی" + echo -e "${Green}5.${Font} Русский" + echo -e "${Green}6.${Font} 한국어" local lang_choice - read_optimize "$(gettext "请输入数字"): " "lang_choice" "NULL" 1 5 "$(gettext "请输入 1 到 5 之间的有效数字")" + read_optimize "$(gettext "请输入数字"): " "lang_choice" "NULL" 1 6 "$(gettext "请输入 1 到 6 之间的有效数字")" case $lang_choice in 1) @@ -3598,12 +3600,15 @@ set_language() { export LANG=en_US.UTF-8 ;; 3) - export LANG=fa_IR.UTF-8 + export LANG=fr_FR.UTF-8 ;; 4) - export LANG=ru_RU.UTF-8 + export LANG=fa_IR.UTF-8 ;; 5) + export LANG=ru_RU.UTF-8 + ;; + 6) export LANG=ko_KR.UTF-8 ;; *) @@ -3740,6 +3745,7 @@ menu() { echo -e "—————————————— ${GreenW}语言 / Language${Font} ———————" echo -e "${Green}36.${Font} 中文" echo -e " English" + echo -e " Français" echo -e " فارسی " echo -e " Русский" echo -e " 한국어" diff --git a/languages/en/README.md b/languages/en/README.md index cc4a4fa..f77eb97 100644 --- a/languages/en/README.md +++ b/languages/en/README.md @@ -1,6 +1,6 @@ # Xray supports Reality / VLESS WebSocket/gRPC+TLS protocol + Nginx one-click installation script -[简体中文](/README.md) | English | [Русский](/languages/ru/README.md) | [فارسی](/languages/fa/README.md) | [한국어](/languages/ko/README.md) +[简体中文](/README.md) | English | [Français](/languages/fr/README.md) | [Русский](/languages/ru/README.md) | [فارسی](/languages/fa/README.md) | [한국어](/languages/ko/README.md) [![GitHub stars](https://img.shields.io/github/stars/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/stargazers) [![GitHub forks](https://img.shields.io/github/forks/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/network) [![GitHub issues](https://img.shields.io/github/issues/hello-yunshu/Xray_bash_onekey)](https://github.com/hello-yunshu/Xray_bash_onekey/issues) @@ -8,7 +8,7 @@ ## Usage Instructions -* You can directly input the command: `idleleo` to manage the script. +* You can directly input the command: `idleleo` to manage the script. ( [View the background story of `idleleo`](https://github.com/hello-yunshu/Xray_bash_onekey/wiki/Backstory#the-immortal-path-of-idelao-the-legend-of-idleleo) ) * Use DeepSeek AI for accurate translations in multiple languages. * It is recommended to use Nginx as a reverse proxy for Reality, which can be installed in the script. * It is recommended to enable fail2ban, which can be installed in the script. diff --git a/languages/fa/README.md b/languages/fa/README.md index 456d595..197db2f 100644 --- a/languages/fa/README.md +++ b/languages/fa/README.md @@ -1,6 +1,6 @@ # Xray supports Reality / VLESS WebSocket/gRPC+TLS protocol + Nginx one-click installation script -[简体中文](/README.md) | [English](/languages/en/README.md) | [Русский](/languages/ru/README.md) | فارسی | [한국어](/languages/ko/README.md) +[简体中文](/README.md) | [English](/languages/en/README.md) | [Français](/languages/fr/README.md) | [Русский](/languages/ru/README.md) | فارسی | [한국어](/languages/ko/README.md) [![GitHub stars](https://img.shields.io/github/stars/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/stargazers) [![GitHub forks](https://img.shields.io/github/forks/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/network) [![GitHub issues](https://img.shields.io/github/issues/hello-yunshu/Xray_bash_onekey)](https://github.com/hello-yunshu/Xray_bash_onekey/issues) @@ -8,7 +8,7 @@ ## راهنماي استفاده -* شما می‌توانید مستقیماً دستور: `idleleo` را وارد کنید تا اسکریبت را مدیریت کنید. +* می‌توانید دستور `idleleo` را مستقیماً وارد کنید تا اسکریپت را مدیریت کنید. ( [مشاهده پیشینهٔ داستان `idleleo`](https://github.com/hello-yunshu/Xray_bash_onekey/wiki/Backstory#%D8%B1%D8%A7%D9%87-%D9%81%D8%B1%D8%A7%D9%85%D9%88%D8%B4%DA%A9%D9%86%D9%86%D8%AF%D9%87-%D8%A7%D9%84%D9%87%DB%8C-%D8%AF%D8%A7%D8%B3%D8%AA%D8%A7%D9%86-idleleo) ) * با استفاده از DeepSeek AI ترجمه دقیق به چند زبان رو انجام بده. * برای Reality، استفاده از Nginx به عنوان پیشگام توصیه می‌شود که در اسکریبت قابل نصب است. * توصیه می‌شود fail2ban را فعال کنید که در اسکریпт قابل نصب است. diff --git a/languages/fr/README.md b/languages/fr/README.md new file mode 100644 index 0000000..e895903 --- /dev/null +++ b/languages/fr/README.md @@ -0,0 +1,105 @@ +# Xray prend en charge Reality / VLESS WebSocket/gRPC+TLS avec Nginx - Script d'installation automatique + +[简体中文](/README.md) | [English](/languages/en/README.md) | Français | [Русский](/languages/ru/README.md) | [فارسی](/languages/fa/README.md) | [한국어](/languages/ko/README.md) + +[![GitHub stars](https://img.shields.io/github/stars/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/stargazers) [![GitHub forks](https://img.shields.io/github/forks/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/network) [![GitHub issues](https://img.shields.io/github/issues/hello-yunshu/Xray_bash_onekey)](https://github.com/hello-yunshu/Xray_bash_onekey/issues) + +> Merci à JetBrains pour l'autorisation de développement open source non commercial + +## Instructions d'utilisation + +* Vous pouvez simplement entrer la commande : `idleleo` pour gérer le script. ( [Voir l'histoire de `idleleo`](https://github.com/hello-yunshu/Xray_bash_onekey/wiki/Backstory#la-voie-immortelle-didleleo) ) +* Traduction multilingue précise réalisée avec l'IA DeepSeek. +* Il est recommandé d'utiliser Nginx devant Reality, vous pouvez l'installer directement via le script. +* Il est conseillé d'activer fail2ban, vous pouvez l'installer via le script. +* Utilisation de la proposition de lien de partage de [@DuckSoft](https://github.com/DuckSoft) (beta), compatible avec Qv2ray, V2rayN, V2rayNG. +* Utilisation de la proposition du projet [XTLS](https://github.com/XTLS/Xray-core/issues/158), conforme à la norme [UUIDv5](https://tools.ietf.org/html/rfc4122#section-4.3), permettant de mapper une chaîne personnalisée vers un UUID VLESS. +* Instructions d'installation de Reality : [Configurer un serveur Xray avec le protocole Reality](https://hey.run/archives/da-jian-xray-reality-xie-yi-fu-wu-qi). +* Risques liés au protocole Reality : [Risques associés au protocole Reality](https://hey.run/archives/reality-xie-yi-de-feng-xian). +* Accélérer le serveur grâce au protocole Reality : [Accélérer le serveur en utilisant un "bug" du protocole Reality](https://hey.run/archives/use-reality). +* Ajout de la configuration d'équilibrage de charge, tutoriel : [Avancées avec XRay – Configurer un équilibrage de charge backend](https://hey.run/archives/xrayjin-jie-wan-fa---da-jian-hou-duan-fu-wu-qi-fu-zai-jun-heng). +* Ajout de la prise en charge du protocole gRPC, voir : [Avancées avec XRay – Utiliser le protocole gRPC](https://hey.run/archives/xrayjin-jie-wan-fa---shi-yong-grpcxie-yi). + +## Groupe Telegram + +* Groupe de discussion Telegram : [Cliquez sur le lien](https://t.me/+48VSqv7xIIFmZDZl) + +## Préparation + +* Préparer un serveur fonctionnant en dehors de la Chine continentale, disposant d'une IP publique. +* Pour l'installation de Reality, trouver un domaine conforme aux exigences de Xray. +* Pour l'installation avec TLS, préparer un domaine et configurer correctement son enregistrement A. +* Lire la documentation officielle de [Xray](https://xtls.github.io), pour comprendre les protocoles Reality, TLS, WebSocket, gRPC ainsi que les exigences sur le domaine utilisé pour Reality. +* **Installer curl**, les utilisateurs de Centos doivent exécuter : `yum install -y curl` ; les utilisateurs Debian/Ubuntu doivent exécuter : `apt install -y curl`. + +## Méthode d'installation + +Copier et exécuter la commande suivante : + +``` bash +bash <(curl -Ss https://raw.githubusercontent.com/hello-yunshu/Xray_bash_onekey/main/install.sh) +``` + +## Remarques importantes + +* Si vous ne comprenez pas les paramètres proposés par le script, sauf pour les champs obligatoires, utilisez les valeurs par défaut proposées (tapez Entrée à chaque fois). +* Les utilisateurs de Cloudflare doivent activer la fonction CDN après l'installation. +* Ce script nécessite des bases en Linux, une expérience de son utilisation, ainsi qu'une compréhension des réseaux informatiques et des opérations basiques. +* Actuellement, il supporte Debian 9+ / Ubuntu 18.04+ / Centos7+ ; certains modèles Centos peuvent rencontrer des problèmes de compilation, il est donc recommandé de changer de modèle système en cas de difficultés. +* L'auteur fournit un support limité, car il estime ne pas être très compétent. +* Les liens de partage sont en version expérimentale, des changements futurs sont possibles, veuillez vérifier si votre client les supporte. +* Le mappage d'une chaîne personnalisée vers UUIDv5 nécessite que le client le prenne en charge. + +## Remerciements + +* Ce script s'inspire de , merci à wulabing. +* Le script d'accélération TCP provient du projet , merci à ylx2016. + +## Certificats + +Si vous possédez déjà les fichiers de certificat pour le domaine utilisé, veuillez nommer les fichiers crt et key en xray.crt et xray.key, puis les placer dans le répertoire `/etc/idleleo/cert` (créez le répertoire si nécessaire). Vérifiez les permissions des certificats ainsi que leur date d'expiration. Les certificats personnalisés expirés doivent être renouvelés manuellement. + +Le script prend en charge la génération automatique de certificats Let's Encrypt, valables 3 mois, et théoriquement capables de se renouveler automatiquement. + +## Afficher la configuration client + +`cat /etc/idleleo/xray_info.txt` + +## Présentation de Xray + +* Xray est un excellent outil de proxy réseau open source qui vous permet de naviguer sur Internet sans restriction. Il est désormais compatible avec tous les systèmes : Windows, Mac, Android, iOS, Linux, etc. +* Ce script configure automatiquement Xray en un seul clic. Une fois l'installation terminée correctement, il vous suffit de configurer votre client en fonction des résultats affichés pour l'utiliser. +* Veuillez noter : nous vous recommandons fortement de bien comprendre le fonctionnement et les principes de ce programme. + +## Recommandation d'installation unique par serveur + +* Ce script installe par défaut la dernière version du noyau Xray. +* Il est recommandé d'utiliser le port 443 par défaut comme port de connexion. +* Le contenu de brouillage peut être remplacé manuellement. + +## Autres remarques + +* Il est recommandé d'utiliser ce script dans un environnement propre. Si vous êtes débutant, évitez d'utiliser le système Centos. +* Avant de confirmer que ce script fonctionne correctement, veuillez ne pas l'utiliser dans un environnement de production. +* Ce programme dépend de Nginx pour fonctionner. Les utilisateurs ayant installé Nginx via [LNMP](https://lnmp.org) ou d'autres scripts similaires doivent faire attention, car l'utilisation de ce script pourrait entraîner des erreurs imprévues. +* Les utilisateurs de Centos doivent ouvrir les ports nécessaires (par défaut : 80, 443) dans le pare-feu. + +## Démarrage + +Démarrer Xray : `systemctl start xray` + +Arrêter Xray : `systemctl stop xray` + +Démarrer Nginx : `systemctl start nginx` + +Arrêter Nginx : `systemctl stop nginx` + +## Répertoires importants + +Fichier de configuration Xray serveur : `/etc/idleleo/conf/xray/config.json` + +Répertoire Nginx : `/usr/local/nginx` + +Fichiers de certificat : `/etc/idleleo/cert/xray.key` et `/etc/idleleo/cert/xray.crt` — veuillez vérifier les permissions des certificats + +Fichiers de configuration, etc. : `/etc/idleleo` \ No newline at end of file diff --git a/languages/ko/README.md b/languages/ko/README.md index d7d910d..b2ee72f 100644 --- a/languages/ko/README.md +++ b/languages/ko/README.md @@ -1,6 +1,6 @@ # Xray Reality / VLESS WebSocket/gRPC+TLS 프로토콜 + Nginx 일괄 설치 스크립트 -[简体中文](/README.md) | [English](/languages/en/README.md) | [Русский](/languages/ru/README.md) | [فارسی](/languages/fa/README.md) | 한국어 +[简体中文](/README.md) | [English](/languages/en/README.md) | [Français](/languages/fr/README.md) | [Русский](/languages/ru/README.md) | [فارسی](/languages/fa/README.md) | 한국어 [![GitHub stars](https://img.shields.io/github/stars/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/stargazers) [![GitHub forks](https://img.shields.io/github/forks/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/network) [![GitHub issues](https://img.shields.io/github/issues/hello-yunshu/Xray_bash_onekey)](https://github.com/hello-yunshu/Xray_bash_onekey/issues) @@ -8,7 +8,7 @@ ## 사용 방법 -* `idleleo` 명령을 직접 입력하여 스크립트를 관리할 수 있습니다. +* `idleleo` 명령을 직접 입력하여 스크립트를 관리할 수 있습니다. ( [`idleleo` 배경 이야기 보기](https://github.com/hello-yunshu/Xray_bash_onekey/wiki/Backstory#%EB%AC%B4%EB%A6%89%EC%84%A0%EB%8F%84%E6%AD%A6%E9%99%B5%E4%BB%99%E9%81%93-%EC%95%84%EC%9D%B4%EB%93%A4%EB%A0%88%EC%98%A4%EC%9D%98-%EC%A0%84%EC%84%A4) ) * DeepSeek AI를 사용해서 여러 언어를 정확하게 번역해. * Reality는 Nginx 프론트엔드를 권장하며, 스크립트에서 설치할 수 있습니다. * fail2ban 활성화를 권장하며, 스크립트에서 설치할 수 있습니다. diff --git a/languages/ru/README.md b/languages/ru/README.md index 443fa4d..f3ac56c 100644 --- a/languages/ru/README.md +++ b/languages/ru/README.md @@ -1,6 +1,6 @@ # Xray supports Reality / VLESS WebSocket/gRPC+TLS protocol + Nginx one-click installation script -[简体中文](/README.md) | [English](/languages/en/README.md) | Русский | [فارسی](/languages/fa/README.md) | [한국어](/languages/ko/README.md) +[简体中文](/README.md) | [English](/languages/en/README.md) | [Français](/languages/fr/README.md) | Русский | [فارسی](/languages/fa/README.md) | [한국어](/languages/ko/README.md) [![GitHub stars](https://img.shields.io/github/stars/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/stargazers) [![GitHub forks](https://img.shields.io/github/forks/hello-yunshu/Xray_bash_onekey?color=%230885ce)](https://github.com/hello-yunshu/Xray_bash_onekey/network) [![GitHub issues](https://img.shields.io/github/issues/hello-yunshu/Xray_bash_onekey)](https://github.com/hello-yunshu/Xray_bash_onekey/issues) @@ -8,7 +8,7 @@ ## Инструкция по использованию -* Вы можете напрямую ввести команду: `idleleo` для управления скриптом. +* Вы можете напрямую ввести команду: `idleleo` для управления скриптом. ( [Посмотреть предысторию `idleleo`](https://github.com/hello-yunshu/Xray_bash_onekey/wiki/Backstory#%D0%BF%D1%83%D1%82%D1%8C-%D0%B1%D0%B5%D1%81%D1%81%D0%BC%D0%B5%D1%80%D1%82%D0%BD%D0%BE%D0%B3%D0%BE-idleleo-%D0%BB%D0%B5%D0%B3%D0%B5%D0%BD%D0%B4%D0%B0-%D0%BE-idleleo) ) * Используй DeepSeek AI для точного перевода на несколько языков. * Для Reality рекомендуется использовать Nginx как обратный прокси, который можно установить через скрипт. * Рекомендуется включить fail2ban, который также можно установить через скрипт. diff --git a/translate.py b/translate.py index 3b0bbfd..1ca2f33 100644 --- a/translate.py +++ b/translate.py @@ -44,18 +44,13 @@ def update_version(version_file): def contains_chinese(text): return any('\u4e00' <= char <= '\u9fff' for char in text) -def is_english_dominant(text, threshold=0.4): - english_count = sum(1 for char in text if char.isascii()) - total_count = len(text) - return english_count / total_count > threshold - -def contains_target_language_characters(text, target_lang): - try: - detected_lang = detect(text) - return detected_lang == target_lang - except Exception as e: - print(f"Language detection failed: {e}") - return False +# def contains_target_language_characters(text, target_lang): +# try: +# detected_lang = detect(text) +# return detected_lang == target_lang +# except Exception as e: +# print(f"Language detection failed: {e}") +# return False def translate_text_deepseek(text, target_lang): api_key = os.getenv("AI_API_KEY") @@ -161,9 +156,7 @@ def translate_po_file(input_file, output_file, target_lang_code, target_lang_nam # 检查翻译结果是否仍包含中文或需要回退翻译 if (contains_chinese(translated_text) or - needs_fallback_translation(translated_text) or - not contains_target_language_characters(translated_text, target_lang_code) or - is_english_dominant(translated_text)): + needs_fallback_translation(translated_text)): print(f"Translation does not meet criteria using DeepSeek. Using Google Translate...") translated_text = translate_text_google(msgid_text, target_lang_code) @@ -184,7 +177,7 @@ def translate_po_file(input_file, output_file, target_lang_code, target_lang_nam if attempt == max_retries - 1: raise e print(f"Retry {attempt + 1}/{max_retries} for: {msgid_text}") - time.sleep(0.3) # 重试前等待更长时间 + time.sleep(0.1) # 重试前等待更长时间 except Exception as e: print(f"Translation failed for: {msgid_text}") print(f"Error: {e}") @@ -230,8 +223,8 @@ def translate_po_file(input_file, output_file, target_lang_code, target_lang_nam f.write(content) if __name__ == '__main__': - for lang_code, lang_name in [('en', 'English'), ('fa', 'Persian'), ('ru', 'Russian'), ('ko', 'Korean')]: + for lang_code, lang_name in [('en', 'English'), ('fa', 'Persian'), ('ru', 'Russian'), ('ko', 'Korean'), ('fr', 'French')]: print(f"\nTranslating to {lang_name} ({lang_code})...") input_file = f'po/{lang_code}.po' output_file = f'po/{lang_code}.po' - translate_po_file(input_file, output_file, lang_code, lang_name) + translate_po_file(input_file, output_file, lang_code, lang_name) \ No newline at end of file