添加可选的翻译功能
This commit is contained in:
@@ -451,3 +451,11 @@ def translateTag_to_sc(tag):
|
||||
return tag
|
||||
else:
|
||||
return tag
|
||||
|
||||
def translate(src:str,target_language:str="zh_cn"):
|
||||
url = f"https://translate.google.cn/translate_a/single?client=gtx&dt=t&dj=1&ie=UTF-8&sl=auto&tl={target_language}&q={src}"
|
||||
result = get_html(url=url,return_type="object")
|
||||
|
||||
translate_list = [i["trans"] for i in result.json()["sentences"]]
|
||||
|
||||
return "".join(translate_list)
|
||||
|
||||
Reference in New Issue
Block a user