更新翻译

This commit is contained in:
gfdgd xi 2022-12-06 09:38:01 +08:00
parent 51635cf2c0
commit ed39b338c9
9 changed files with 118 additions and 108 deletions

View File

@ -19,6 +19,7 @@ import requests
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
sys.path.append(f"{programPath}/../")
from Model import *
from trans import *
from PyQt5 import QtCore, QtGui, QtWidgets
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
# UI 布局(自动生成)
@ -74,7 +75,12 @@ class Ui_MainWindow(object):
self.verticalLayout_2.addLayout(self.horizontalLayout)
MainWindow.setCentralWidget(self.centralWidget)
# 菜单栏
_translate = QtCore.QCoreApplication.translate
#_translate = QtCore.QCoreApplication.translate
if not get_now_lang() == "zh_CN.UTF-8":
transla = Trans("en_US", f"{programPath}/trans/deepin-wine-runner-qemu-download.json")
else:
transla = Trans("zh_CN")
_translate = transla.transe
self.menu = MainWindow.menuBar()
self.changeSources = self.menu.addMenu(_translate("MainWindow", "更换源"))
self.gitlinkAction = QtWidgets.QAction(_translate("MainWindow", "Gitlink 源(推荐)"))
@ -422,65 +428,3 @@ if __name__ == "__main__":
ui.centralWidget.setWindowIcon(QtGui.QIcon(f"{programPath}/../deepin-wine-runner.svg"))
app.exec_()
exit()
#!/usr/bin/env python3
import os
import sys
import json
import traceback
import req as requests
import PyQt5.QtGui as QtGui
import PyQt5.QtCore as QtCore
import PyQt5.QtWidgets as QtWidgets
from Model import *
sources = [
"https://code.gitlink.org.cn/gfdgd_xi/deepin-wine-runner-ubuntu-image/raw/branch/master/Sandbox"
]
sourceIndex = 0
def ReadTXT(path: str) -> str:
with open(path, "r") as file:
things = file.read()
return things
def WriteTXT(path: str, text: str) -> None:
with open(path, "w") as file:
file.write(text)
def CheckVersion(arch: str) -> bool:
information = requests.get(f"{sources[sourceIndex]}/{arch}/lists.json").json()[0]
if not os.path.exists(f"{homePath}/.deepin-wine-runner-ubuntu-images/{arch}"):
return False
localInformation = json.loads(ReadTXT(f"{homePath}/.deepin-wine-runner-ubuntu-images/lists.json"))
try:
if localInformation["arch"][0] == information[0]:
print("版本相同")
return True
return False
except:
return False
if __name__ == "__main__":
programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
homePath = os.getenv("HOME")
app = QtWidgets.QApplication(sys.argv)
if os.system("which qemu-i386-static"):
if QtWidgets.QMessageBox.question(None, "提示", "检测到您未安装 qemu-user-static是否安装") == QtWidgets.QMessageBox.Yes:
OpenTerminal(f"pkexec bash '{programPath}/ShellList/InstallQemuUserStatic.sh'")
exit()
while True:
archList = requests.get(f"{sources[sourceIndex]}/lists.json").json()
choose = QtWidgets.QInputDialog.getItem(None, "选择", "选择要安装/更新的镜像对应的架构", archList, 0, False)
if not choose[1]:
QtWidgets.QMessageBox.information(None, "提示", "用户取消操作")
break
try:
if CheckVersion(choose[0]):
QtWidgets.QMessageBox.information(None, "提示", "最新版本,无需操作")
continue
except:
traceback.print_exc()
QtWidgets.QMessageBox.critical(None, "出现错误", traceback.format_exc())
continue

View File

@ -2238,14 +2238,19 @@ print(wine)
###########################
# 程序信息
###########################
# 语言载入
if not get_now_lang() == "zh_CN.UTF-8":
transla = Trans("en_US", f"{programPath}/trans/deepin-wine-runner.json")
else:
transla = Trans("zh_CN")
iconPath = "{}/deepin-wine-runner.svg".format(programPath)
#iconPath = "{}/Icon/Program/wine运行器.png".format(programPath)
programUrl = "https://gitee.com/gfdgd-xi/deep-wine-runner\nhttps://github.com/gfdgd-xi/deep-wine-runner\nhttps://www.gitlink.org.cn/gfdgd_xi/deep-wine-runner\nhttps://gfdgd-xi.github.io"
information = json.loads(readtxt(f"{programPath}/information.json"))
version = information["Version"]
goodRunSystem = "常见 Linux 发行版"
goodRunSystem = transla.transe("U", "常见 Linux 发行版")
thankText = ""
tips = '''<h4>提示:</h4>
tips = transla.transe("U", '''<h4>提示:</h4>
1使用终端运行该程序可以看到 wine 以及程序本身的提示和报错
2wine 32 位和 64 位的容器互不兼容
3所有的 wine winetricks 均需要自行安装可以从 菜单栏=>程序 里面进行安装
@ -2262,8 +2267,8 @@ exe路径\' 参数 \'
10如果是使用 Deepin 23 Wine 安装脚本请切记安装过程会临时添加 Deepin 20 apt 不要中断安装以及
<b>千万不要中断后不删除源的情况下 apt upgrade </b>中断后只需重新打开脚本输入 repair 或者随意安装一个 Wine会自动执行恢复操作即可
以及此脚本安装的 Wine 无法保证 100% 能使用以及副作用是会提示
<code>N: 鉴于仓库 'https://community-packages.deepin.com/beige beige InRelease' 不支持 'i386' 体系结构跳过配置文件 'main/binary-i386/Packages' 的获取</code>'''
updateThingsString = '''※1、支持使用 Qemu + Chroot 跨运行 Wine 以及指定程序的功能;
<code>N: 鉴于仓库 'https://community-packages.deepin.com/beige beige InRelease' 不支持 'i386' 体系结构跳过配置文件 'main/binary-i386/Packages' 的获取</code>''')
updateThingsString = transla.transe("U", '''※1、支持使用 Qemu + Chroot 跨运行 Wine 以及指定程序的功能;
2提供了简易打包器以用于打包简易 deb
3支持下载配置过的 Qemu + Chroot 容器
4支持解压指定 deb 的内打包好的容器
@ -2271,23 +2276,24 @@ updateThingsString = '''※1、支持使用 Qemu + Chroot 跨运行 Wine 以及
6优化非基于生态适配脚本的打包器内容自动填充功能
7新增程序论坛和教程入口
8优化程序文案
'''
''')
for i in information["Thank"]:
thankText += f"{i}\n"
updateTime = "2022年12月04日"
aboutProgram = transla.transe("U", """<p>Wine运行器是一个能让Linux用户更加方便地运行Windows应用的程序内置了对Wine图形化的支持、各种Wine工具、自制的Wine程序打包器和运行库安装工具等。</p>
<p>它同时还内置了基于VirtualBox制作的专供小白使用的Windows虚拟机安装工具可以做到只需下载系统镜像并点击安装即可无需考虑虚拟机的安装创建分区等操作</p>
<pre>
一个图形化了如下命令的程序最简单格式
<code>env WINEPREFIX=容器路径 winewine的路径 可执行文件路径</code>
让你可以简易方便的使用 wine""")
about = f'''<style>
a:link, a:active {{
text-decoration: none;
}}
</style>
<h1>关于</h1>
<p>Wine运行器是一个能让Linux用户更加方便地运行Windows应用的程序内置了对Wine图形化的支持各种Wine工具自制的Wine程序打包器和运行库安装工具等</p>
<p>它同时还内置了基于VirtualBox制作的专供小白使用的Windows虚拟机安装工具可以做到只需下载系统镜像并点击安装即可无需考虑虚拟机的安装创建分区等操作</p>
<pre>
一个图形化了如下命令的程序最简单格式
<code>env WINEPREFIX=容器路径 winewine的路径 可执行文件路径</code>
让你可以简易方便的使用 wine
{aboutProgram}
版本{version}
适用平台{goodRunSystem}@VersionForType@
@ -2311,7 +2317,7 @@ Qt 版本:{QtCore.qVersion()}
<pre>星火应用商店https://spark-app.store/
Deepin 官网https://www.deepin.org
Deepin 论坛https://bbs.deepin.org
非官方论坛https://gfdgdxi.flarum.cloud/</pre>
论坛https://gfdgdxi.flarum.cloud/</pre>
<hr>
<h1>©2020~{time.strftime("%Y")} gfdgd xi为什么您不喜欢熊出没和阿布呢</h1>'''
title = "Wine 运行器 {}".format(version)
@ -2333,14 +2339,6 @@ print(iconList)
# 读取主题
# Qt 窗口
app = QtWidgets.QApplication(sys.argv)
# 语言载入
if not get_now_lang() == "zh_CN.UTF-8":
#trans = QtCore.QTranslator()
#trans.load(f"{programPath}/LANG/deepin-wine-runner-en_US.qm")
#app.installTranslator(trans)
transla = Trans("en_US", f"{programPath}/trans/deepin-wine-runner.json")
else:
transla = Trans("zh_CN")
window = QtWidgets.QMainWindow()
window.setWindowTitle(title)
widget = QtWidgets.QWidget()
@ -2800,8 +2798,8 @@ help.addSeparator()
wikiHelp = QtWidgets.QAction(transla.transe("U", "程序 Wiki"))
help.addAction(wikiHelp)
videoHelp = help.addMenu(transla.transe("U", "视频教程"))
easyHelp = QtWidgets.QAction("简易使用教程")
buildHelp = QtWidgets.QAction("打包教程")
easyHelp = QtWidgets.QAction(transla.transe("U", "简易使用教程"))
buildHelp = QtWidgets.QAction(transla.transe("U", "打包教程"))
videoHelp.addAction(easyHelp)
videoHelp.addAction(buildHelp)
help.addSeparator()

View File

@ -19,6 +19,7 @@ import subprocess
import PyQt5.QtGui as QtGui
import PyQt5.QtCore as QtCore
import PyQt5.QtWidgets as QtWidgets
from trans import *
###################
# 程序所需事件
@ -147,6 +148,10 @@ def NameChange(packageOrBotton: int):
elif packageOrBotton == 1 and bottonName.text() != packageName.text():
lockB = True
# 获取当前语言
def get_now_lang()->"获取当前语言":
return os.getenv('LANG')
###########################
# 程序信息
###########################
@ -154,7 +159,12 @@ programPath = os.path.split(os.path.realpath(__file__))[0] # 返回 string
information = json.loads(readtxt(f"{programPath}/information.json"))
version = information["Version"]
iconPath = "{}/deepin-wine-runner.svg".format(programPath)
tips = """第一个文本框是应用程序中文名
# 语言载入
if not get_now_lang() == "zh_CN.UTF-8":
transla = Trans("en_US", f"{programPath}/trans/packager.json")
else:
transla = Trans("zh_CN")
tips = transla.transe("U", """第一个文本框是应用程序中文名
第二个文本框是应用程序英文名
第三个文本框是最终生成的包的描述
第四个选择框是desktop文件中的分类
@ -164,7 +174,7 @@ desktop文件中StartupWMClass字段。用于让桌面组件将窗口类名与de
第六个输入框是最终生成的包的包名,包名的命名规则以deepin开头加官网域名需要前后对调位置如还不能区分再加上应用名
最后一个是最终生成的包的版本号版本号命名规则应用版本号+deepin+数字
提示包名和容器名相同无法设置为不相同如果需要设置为不相同需要用另一个非基于生态适配脚本的打包器
"""
""")
###########################
# 窗口创建
@ -186,22 +196,22 @@ packageName = QtWidgets.QLineEdit()
bottonName = QtWidgets.QLineEdit()
versionName = QtWidgets.QLineEdit()
controlFrame = QtWidgets.QHBoxLayout()
buildDeb = QtWidgets.QPushButton("打包")
debPath = QtWidgets.QPushButton("deb 包生成目录")
buildDeb = QtWidgets.QPushButton(transla.transe("U", "打包"))
debPath = QtWidgets.QPushButton(transla.transe("U", "deb 包生成目录"))
buildDeb.setSizePolicy(size)
debPath.setSizePolicy(size)
commandReturn = QtWidgets.QTextBrowser()
typeName.addItems(["Network", "Chat", "Audio", "Video", "Graphics", "Office", "Translation", "Development", "Utility", "System"])
controlFrame.addWidget(buildDeb)
controlFrame.addWidget(debPath)
widgetLayout.addWidget(QtWidgets.QLabel("程序中文名:"), 0, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel("程序英文名:"), 1, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel("包描述:"), 2, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel("程序分类:"), 3, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel("程序在 Wine 容器的位置:"), 4, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel("包名:"), 5, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel("容器名:"), 6, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel("版本号:"), 7, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel(transla.transe("U", "程序中文名:")), 0, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel(transla.transe("U", "程序英文名:")), 1, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel(transla.transe("U", "包描述:")), 2, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel(transla.transe("U", "程序分类:")), 3, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel(transla.transe("U", "程序在 Wine 容器的位置:")), 4, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel(transla.transe("U", "包名:")), 5, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel(transla.transe("U", "容器名:")), 6, 0, 1, 1)
widgetLayout.addWidget(QtWidgets.QLabel(transla.transe("U", "版本号:")), 7, 0, 1, 1)
widgetLayout.addWidget(chineseName, 0, 1, 1, 1)
widgetLayout.addWidget(englishName, 1, 1, 1, 1)
widgetLayout.addWidget(debDescription, 2, 1, 1, 1)
@ -221,22 +231,22 @@ window.setCentralWidget(widget)
window.resize(int(window.frameGeometry().width() * 1.5), int(window.frameGeometry().height()))
window.setWindowIcon(QtGui.QIcon(iconPath))
menu = window.menuBar()
programMenu = menu.addMenu("程序")
exit = QtWidgets.QAction("退出")
programMenu = menu.addMenu(transla.transe("U", "程序"))
exit = QtWidgets.QAction(transla.transe("U", "退出"))
exit.triggered.connect(window.close)
uploadSparkStore = menu.addMenu(QtCore.QCoreApplication.translate("U", "投稿到星火应用商店"))
uploadSparkStoreWebsize = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "从网页端投稿"))
uploadSparkStore = menu.addMenu(transla.transe("U", "投稿到星火应用商店"))
uploadSparkStoreWebsize = QtWidgets.QAction(transla.transe("U", "从网页端投稿"))
if os.path.exists("/opt/spark-store-submitter/bin/spark-store-submitter"):
uploadSparkStoreProgram = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "使用投稿器投稿(推荐)"))
uploadSparkStoreProgram = QtWidgets.QAction(transla.transe("U", "使用投稿器投稿(推荐)"))
else:
uploadSparkStoreProgram = QtWidgets.QAction(QtCore.QCoreApplication.translate("U", "使用投稿器投稿(推荐,请先安装投稿器)"))
uploadSparkStoreProgram = QtWidgets.QAction(transla.transe("U", "使用投稿器投稿(推荐,请先安装投稿器)"))
uploadSparkStoreProgram.setDisabled(True)
uploadSparkStore.addAction(uploadSparkStoreProgram)
uploadSparkStore.addAction(uploadSparkStoreWebsize)
uploadSparkStoreWebsize.triggered.connect(lambda: webbrowser.open_new_tab("https://upload.deepinos.org"))
uploadSparkStoreProgram.triggered.connect(lambda: threading.Thread(target=os.system, args=["/opt/spark-store-submitter/bin/spark-store-submitter"]).start())
helpMenu = menu.addMenu("帮助")
help = QtWidgets.QAction("帮助")
helpMenu = menu.addMenu(transla.transe("U", "帮助"))
help = QtWidgets.QAction(transla.transe("U", "帮助"))
help.triggered.connect(ShowHelp)
helpMenu.addAction(help)
programMenu.addAction(exit)

View 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]
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
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

View File

@ -0,0 +1 @@
{"第一个文本框是应用程序中文名\n第二个文本框是应用程序英文名\n第三个文本框是最终生成的包的描述\n第四个选择框是desktop文件中的分类\n第五个输入框是程序在 Wine 容器的位置,以 c:\\XXX 的形式,盘符必须小写,用反斜杠,如果路径带用户名的话会自动替换为$USER\n而 StartupWMClass 字段将会由程序自动生成,作用如下:\ndesktop文件中StartupWMClass字段。用于让桌面组件将窗口类名与desktop文件相对应。这个值为实际运行的主程序EXE的文件名wine/crossover在程序运行后会将文件名设置为窗口类名\n第六个输入框是最终生成的包的包名,包名的命名规则以deepin开头加官网域名需要前后对调位置如还不能区分再加上应用名\n最后一个是最终生成的包的版本号版本号命名规则应用版本号+deepin+数字\n提示包名和容器名相同无法设置为不相同如果需要设置为不相同需要用另一个非基于生态适配脚本的打包器\n": "The first is the application Chinese name text box\nThe second text box is application English name\nThe third one is a text box that ultimately make the description of the package\nA fourth option box is a classification in the desktop file\nThe fifth input box is program in Wine vessel position, to the c: \\ XXX's form, the drive must be lowercase, with a backslash, if the path with the USER name will be automatically replaced with $USER\nWhile StartupWMClass fields will be automatically generated by the program, function is as follows:\nThe desktop file StartupWMClass fields.\nThe sixth input box is the package name of the resulting package, the package name begin with deepin naming rules, plus the website domain name (need change over) before and after, if can't distinguish between plus application name\nThe last one is the resulting package version number, version number naming rules: application version number + deepin + number\nTip: package name is the same as the container name, cannot be set to different, if you need to set up for different, need to use another based on the ecological adaptation of the script package", "投稿到星火应用商店": "Contribute to spark the app store", "从网页端投稿": "From the web", "使用投稿器投稿(推荐)": "Use contribute contributes (recommended)", "打包": "packaging", "deb 包生成目录": "Deb package generated directory", "程序中文名:": "Program name:", "程序英文名:": "English name:", "包描述:": "Package description:", "程序分类:": "Program classification:", "程序在 Wine 容器的位置:": "The location of the program in Wine container:", "包名:": "Package name:", "容器名:": "Vessel name:", "版本号:": "The version number:", "程序": "The program", "退出": "exit", "帮助": "help"}

View File

@ -6,6 +6,7 @@ import traceback
class Trans():
isTrans = False
unCloudTrans = True
word = {}
fileName = ""
@ -29,6 +30,8 @@ class Trans():
try:
return self.word[text]
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"]

View 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)"}

File diff suppressed because one or more lines are too long