From c44031548809cb1a53cc5e10c81adcd5c500a3e3 Mon Sep 17 00:00:00 2001 From: lededev Date: Wed, 20 Oct 2021 23:07:37 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=89=8D=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=E8=AF=AD=E8=A8=80=EF=BC=8C=E5=B7=B2=E7=BB=8F=E6=98=AF=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E4=BA=86=E4=B8=8D=E5=BF=85=E7=BF=BB=E8=AF=91=EF=BC=8C?= =?UTF-8?q?=E5=8F=AA=E7=BF=BB=E8=AF=91=E6=97=A5=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ADC_function.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ADC_function.py b/ADC_function.py index 12fecce..36be657 100755 --- a/ADC_function.py +++ b/ADC_function.py @@ -511,6 +511,9 @@ def translate( delay: int = 0, ): trans_result = "" + # 中文句子如果包含&等符号会被谷歌翻译截断损失内容,而且中文翻译到中文也没有意义,故而忽略,只翻译带有日语假名的 + if not is_japanese(src): + return src if engine == "google-free": gsite = config.getInstance().get_translate_service_site() if not re.match('^translate\.google\.(com|com\.\w{2}|\w{2})$', gsite): @@ -620,3 +623,7 @@ def file_modification_days(filename) -> int: def file_not_exist_or_empty(filepath) -> bool: return not os.path.isfile(filepath) or os.path.getsize(filepath) == 0 + +# 日语简单检测 +def is_japanese(s) -> bool: + return bool(re.search(r'[\u3040-\u309F\u30A0-\u30FF\uFF66-\uFF9F]', s, re.UNICODE))