mirror of
https://gitee.com/gfdgd-xi/deep-wine-runner
synced 2025-12-14 19:12:04 +08:00
初步精简
This commit is contained in:
53
trans/__init__.py
Normal file
53
trans/__init__.py
Normal file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import json
|
||||
import requests
|
||||
import traceback
|
||||
|
||||
class Trans():
|
||||
isTrans = False
|
||||
unCloudTrans = True
|
||||
word = {}
|
||||
fileName = ""
|
||||
|
||||
def __init__(self, lang="zh_CN", fileName=f"trans.json") -> None:
|
||||
self.fileName = fileName
|
||||
self.isTrans = (lang != "zh_CN")
|
||||
if self.isTrans:
|
||||
try:
|
||||
if not os.path.exists(fileName):
|
||||
with open(fileName, "w") as file:
|
||||
file.write("{}")
|
||||
with open(fileName, "r") as file:
|
||||
self.word = json.loads(file.read())
|
||||
except:
|
||||
traceback.print_exc()
|
||||
self.isTrans = False
|
||||
|
||||
def transe(self, temp, text) -> str:
|
||||
if not self.isTrans:
|
||||
return text
|
||||
try:
|
||||
return self.word[text].replace("(", "(").replace(")", ")")
|
||||
except:
|
||||
if self.unCloudTrans:
|
||||
return text
|
||||
# 机翻
|
||||
data = { 'doctype': 'json', 'type': 'auto','i': text}
|
||||
jsonReturn = requests.post("http://fanyi.youdao.com/translate", data=data).json()["translateResult"]
|
||||
transText = ""
|
||||
for i in jsonReturn:
|
||||
print(i[0])
|
||||
transText += f'{i[0]["tgt"]}\n'
|
||||
if "\n" in text:
|
||||
transText = transText.replace("\n\n", "\n")[:-1]
|
||||
else:
|
||||
transText = transText[:-1]
|
||||
self.word[text] = transText.replace("(", "(").replace(")", ")")
|
||||
try:
|
||||
with open(self.fileName, "w") as file:
|
||||
file.write(json.dumps(self.word, ensure_ascii=False))
|
||||
except:
|
||||
traceback.print_exc()
|
||||
print(f"{text}=>{transText}")
|
||||
return transText
|
||||
BIN
trans/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
trans/__pycache__/__init__.cpython-37.pyc
Normal file
Binary file not shown.
1
trans/deepin-wine-packager.json
Normal file
1
trans/deepin-wine-packager.json
Normal file
File diff suppressed because one or more lines are too long
1
trans/deepin-wine-runner-qemu-download.json
Normal file
1
trans/deepin-wine-runner-qemu-download.json
Normal file
@@ -0,0 +1 @@
|
||||
{"更换源": "Change the source", "Gitlink 源(推荐)": "Gitlink source (recommended)", "备用源(只支持 IPv6 用户)": "The alternate source (only support IPv6 users)", "本地测试源(127.0.0.1)": "Local test source (127.0.0.1)", "使用前须知:\n1、Qemu 跨架构效率较低,如果有条件建议优先使用 box86、exagear 等效率较高的转换层;\n2、使用此方案需要使用到 Root 权限(需开启管理员模式)并安装 qemu-user-static;\n3、chroot 时候可能会出现问题导致程序闪退或异常,出现该问题重启电脑即可;\n4、在此环境使用 Wine 时,只能读取到您用户目录或本程序文件夹下的文件,其它路径无法读取;\n5、移除容器时请保证在这次打开电脑时没有调用过需要删除容器,如果有调用过建议重启电脑后再移除;\n6、暂时属于测试功能;": "Instructions before use:\n1, Qemu across architecture efficiency is low, if there is condition is preferred to use box86, exagear high efficiency transformation layer;\n2, use this program to need to use the Root administrator mode (open) and install qemu - user - static;\n3, when chroot flash back problems may cause the program or abnormal, the problems to restart the computer;\n4, in this environment using Wine, can only read your user directory or folder of the program files, other path cannot read;\n5, remove the container please make sure that no calls while in the open a computer need to delete the container, if there is a call after advice to restart the computer to remove;\n6, a temporary belong to test functionality;"}
|
||||
1
trans/deepin-wine-runner.json
Normal file
1
trans/deepin-wine-runner.json
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user