From c2464921a414ec4bdca3f4e6b3f67690fed6ec5d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?=
<101191390+HIllya51@users.noreply.github.com>
Date: Wed, 1 May 2024 18:10:17 +0800
Subject: [PATCH] fix
Update winsharedutils.py
Update th.json
1
---
.../LunaTranslator/LunaTranslator.py | 2 --
LunaTranslator/LunaTranslator/gobject.py | 22 -------------------
.../LunaTranslator/gui/transhist.py | 20 ++++-------------
.../LunaTranslator/winsharedutils.py | 12 ++++++++--
.../files/defaultconfig/config.json | 4 ++--
LunaTranslator/files/lang/ar.json | 1 -
LunaTranslator/files/lang/cht.json | 1 -
LunaTranslator/files/lang/en.json | 1 -
LunaTranslator/files/lang/es.json | 1 -
LunaTranslator/files/lang/fr.json | 1 -
LunaTranslator/files/lang/it.json | 1 -
LunaTranslator/files/lang/ja.json | 1 -
LunaTranslator/files/lang/ko.json | 1 -
LunaTranslator/files/lang/pl.json | 1 -
LunaTranslator/files/lang/ru.json | 1 -
LunaTranslator/files/lang/th.json | 1 -
LunaTranslator/files/lang/tr.json | 1 -
LunaTranslator/files/lang/uk.json | 1 -
LunaTranslator/files/lang/vi.json | 1 -
LunaTranslator/files/lang/zh.json | 1 -
plugins/exec/PyStand.cpp | 2 +-
21 files changed, 17 insertions(+), 60 deletions(-)
diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py
index aeb84c0d..f7606415 100644
--- a/LunaTranslator/LunaTranslator/LunaTranslator.py
+++ b/LunaTranslator/LunaTranslator/LunaTranslator.py
@@ -808,8 +808,6 @@ class MAINUI:
def mainuiloadafter(self):
- gobject.overridestdio()
-
self.safeloadprocessmodels()
self.prepare()
self.startxiaoxueguan()
diff --git a/LunaTranslator/LunaTranslator/gobject.py b/LunaTranslator/LunaTranslator/gobject.py
index 67bf0e03..4294e17b 100644
--- a/LunaTranslator/LunaTranslator/gobject.py
+++ b/LunaTranslator/LunaTranslator/gobject.py
@@ -15,23 +15,6 @@ def GetDllpath(_, base=None):
return os.path.join(base, _[isbit64])
-class debugoutput(io.IOBase):
- def __init__(self, idx, file=sys.stdout) -> None:
- super().__init__()
- self.idx = idx
- self.originfile = file
-
- def write(self, data):
- if self.originfile:
- self.originfile.write(data)
- if "transhis" in dir(baseobject):
- baseobject.transhis.getdebuginfosignal.emit(self.idx, str(data))
-
- def flush(self):
- if self.originfile:
- self.originfile.flush()
-
-
def dopathexists(file):
if not file:
return False
@@ -46,8 +29,3 @@ def dopathexists(file):
def overridepathexists():
# win7上,如果假如没有D盘,然后os.path.exists("D:/..."),就会弹窗说不存在D盘
os.path.exists = dopathexists
-
-
-def overridestdio():
- sys.stderr = debugoutput("stderr", sys.stderr)
- sys.stdout = debugoutput("stdout", sys.stdout)
diff --git a/LunaTranslator/LunaTranslator/gui/transhist.py b/LunaTranslator/LunaTranslator/gui/transhist.py
index f7659920..a89602c7 100644
--- a/LunaTranslator/LunaTranslator/gui/transhist.py
+++ b/LunaTranslator/LunaTranslator/gui/transhist.py
@@ -3,7 +3,7 @@ from PyQt5.QtWidgets import QTabWidget, QTextBrowser, QAction, QMenu, QFileDialo
from PyQt5.QtCore import Qt, pyqtSignal
import qtawesome, functools
-from gui.usefulwidget import closeashidewindow, textbrowappendandmovetoend
+from gui.usefulwidget import closeashidewindow
from myutils.config import globalconfig, _TR
@@ -11,7 +11,6 @@ class transhist(closeashidewindow):
getnewsentencesignal = pyqtSignal(str)
getnewtranssignal = pyqtSignal(str, str)
- getdebuginfosignal = pyqtSignal(str, str)
def __init__(self, parent):
super(transhist, self).__init__(parent, globalconfig, "hist_geo")
@@ -19,17 +18,13 @@ class transhist(closeashidewindow):
# self.setWindowFlags(self.windowFlags()&~Qt.WindowMinimizeButtonHint)
self.getnewsentencesignal.connect(self.getnewsentence)
self.getnewtranssignal.connect(self.getnewtrans)
- self.getdebuginfosignal.connect(self.debugprint)
self.hiderawflag = False
self.hideapiflag = False
- self.setWindowTitle(_TR("历史翻译和调试输出"))
+ self.setWindowTitle(_TR("历史翻译"))
def setupUi(self):
self.setWindowIcon(qtawesome.icon("fa.rotate-left"))
- self.tabwidget = QTabWidget()
- self.tabwidget.setTabPosition(QTabWidget.East)
- self.setCentralWidget(self.tabwidget)
def gettb(_type):
textOutput = QTextBrowser()
@@ -43,12 +38,8 @@ class transhist(closeashidewindow):
return textOutput
self.textOutput = gettb(1)
- self.tabwidget.addTab(self.textOutput, _TR("历史翻译"))
- self.debugoutputs = {}
- for _text in ["stderr", "stdout"]:
- _x = gettb(0)
- self.tabwidget.addTab(_x, _TR(_text))
- self.debugoutputs[_text] = _x
+ self.setCentralWidget(self.textOutput)
+
self.hiding = True
def showmenu(self, tb, flag, p):
@@ -79,9 +70,6 @@ class transhist(closeashidewindow):
self.hideapiflag = not self.hideapiflag
- def debugprint(self, idx, sentence):
- textbrowappendandmovetoend(self.debugoutputs[idx], sentence, False)
-
def getnewsentence(self, sentence):
sentence = "
" if globalconfig["hist_split"] else "\n" + sentence
diff --git a/LunaTranslator/LunaTranslator/winsharedutils.py b/LunaTranslator/LunaTranslator/winsharedutils.py
index 13e3cee2..dacd4c0c 100644
--- a/LunaTranslator/LunaTranslator/winsharedutils.py
+++ b/LunaTranslator/LunaTranslator/winsharedutils.py
@@ -267,8 +267,16 @@ def queryversion(exe):
startdarklistener = utilsdll.startdarklistener
startdarklistener.restype = HANDLE
-SetTheme = utilsdll._SetTheme
-SetTheme.argtypes = HWND, c_bool, c_int
+_SetTheme = utilsdll._SetTheme
+_SetTheme.argtypes = HWND, c_bool, c_int
+
+
+def SetTheme(hwnd, dark, backdrop):
+ try: # win7 x86 crash unknown why
+ _SetTheme(hwnd, dark, backdrop)
+ except:
+ pass
+
showintab = utilsdll.showintab
showintab.argtypes = HWND, c_bool
diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json
index d77d2f7c..1561934f 100644
--- a/LunaTranslator/files/defaultconfig/config.json
+++ b/LunaTranslator/files/defaultconfig/config.json
@@ -368,7 +368,7 @@
},
"history": {
"use": true,
- "tip": "显示/隐藏历史翻译和调试输出",
+ "tip": "显示/隐藏历史翻译",
"icon": "fa.rotate-left"
},
"gamepad_new": {
@@ -505,7 +505,7 @@
},
"_6": {
"use": false,
- "name": "显示/隐藏历史翻译和调试输出",
+ "name": "显示/隐藏历史翻译",
"keystring": ""
},
"_7": {
diff --git a/LunaTranslator/files/lang/ar.json b/LunaTranslator/files/lang/ar.json
index c0c28ff0..06785906 100644
--- a/LunaTranslator/files/lang/ar.json
+++ b/LunaTranslator/files/lang/ar.json
@@ -648,7 +648,6 @@
"Github仓库": "مستودع جيتوب",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "استخدام المعلومات الواردة أعلاه في الترجمة ( عادة ما يكون هناك بعض التحسن ، ولكن يمكن أن يؤدي إلى إبطاء )",
"文本缓冲区长度": "نص طول المخزن المؤقت",
- "显示/隐藏历史翻译和调试输出": "عرض / إخفاء تاريخ الترجمة وتصحيح الأخطاء الناتج",
"历史翻译和调试输出": "تاريخ الترجمة وتصحيح الأخطاء الناتج",
"调试输出": "التصحيح الناتج",
"显示翻译": "عرض الترجمة",
diff --git a/LunaTranslator/files/lang/cht.json b/LunaTranslator/files/lang/cht.json
index 9525c830..f6369499 100644
--- a/LunaTranslator/files/lang/cht.json
+++ b/LunaTranslator/files/lang/cht.json
@@ -648,7 +648,6 @@
"Github仓库": "Github倉庫",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "利用上文資訊翻譯(通常會有一定的效果提升,但會導致變慢)",
"文本缓冲区长度": "文字緩衝區長度",
- "显示/隐藏历史翻译和调试输出": "顯示/隱藏歷史翻譯和調試輸出",
"历史翻译和调试输出": "歷史翻譯和調試輸出",
"调试输出": "調試輸出",
"显示翻译": "顯示翻譯",
diff --git a/LunaTranslator/files/lang/en.json b/LunaTranslator/files/lang/en.json
index 4c8add60..abe3ca1e 100644
--- a/LunaTranslator/files/lang/en.json
+++ b/LunaTranslator/files/lang/en.json
@@ -648,7 +648,6 @@
"Github仓库": "Github warehouse",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "Translate using the information provided in the previous text (usually with some improvement in effectiveness, but it can lead to slower translation)",
"文本缓冲区长度": "Text buffer length",
- "显示/隐藏历史翻译和调试输出": "Show/hide historical translation and debugging output",
"历史翻译和调试输出": "Historical translation and debugging output",
"调试输出": "Debugging output",
"显示翻译": "Display translation",
diff --git a/LunaTranslator/files/lang/es.json b/LunaTranslator/files/lang/es.json
index e44cda61..7a95fd8a 100644
--- a/LunaTranslator/files/lang/es.json
+++ b/LunaTranslator/files/lang/es.json
@@ -648,7 +648,6 @@
"Github仓库": "Almacén github",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "Traducción utilizando la información anterior (generalmente tiene un cierto efecto de mejora, pero puede causar lentitud)",
"文本缓冲区长度": "Longitud del colchón de texto",
- "显示/隐藏历史翻译和调试输出": "Mostrar / ocultar la traducción histórica y depurar la salida",
"历史翻译和调试输出": "Traducción histórica y salida de depuración",
"调试输出": "Salida de depuración",
"显示翻译": "Mostrar traducción",
diff --git a/LunaTranslator/files/lang/fr.json b/LunaTranslator/files/lang/fr.json
index cbdae19a..76bb80a4 100644
--- a/LunaTranslator/files/lang/fr.json
+++ b/LunaTranslator/files/lang/fr.json
@@ -648,7 +648,6 @@
"Github仓库": "Entrepôt github",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "Utilisez les informations ci - dessus pour traduire (il y a généralement une certaine augmentation de l'effet, mais cela entraîne un ralentissement)",
"文本缓冲区长度": "Longueur du tampon de texte",
- "显示/隐藏历史翻译和调试输出": "Afficher / masquer la traduction historique et la sortie de débogage",
"历史翻译和调试输出": "Traduction historique et sortie de débogage",
"调试输出": "Sortie de débogage",
"显示翻译": "Afficher la traduction",
diff --git a/LunaTranslator/files/lang/it.json b/LunaTranslator/files/lang/it.json
index cd1f6dde..114fbbbd 100644
--- a/LunaTranslator/files/lang/it.json
+++ b/LunaTranslator/files/lang/it.json
@@ -648,7 +648,6 @@
"Github仓库": "Magazzino Github",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "Tradurre utilizzando le informazioni fornite nel testo precedente (di solito con qualche miglioramento in efficacia, ma può portare a una traduzione più lenta)",
"文本缓冲区长度": "Lunghezza buffer di testo",
- "显示/隐藏历史翻译和调试输出": "Mostra/nasconde l'output storico di traduzione e debug",
"历史翻译和调试输出": "Risultato storico di traduzione e debug",
"调试输出": "Debug output",
"显示翻译": "Mostra traduzione",
diff --git a/LunaTranslator/files/lang/ja.json b/LunaTranslator/files/lang/ja.json
index 4dfca4b3..dd560aa8 100644
--- a/LunaTranslator/files/lang/ja.json
+++ b/LunaTranslator/files/lang/ja.json
@@ -648,7 +648,6 @@
"Github仓库": "Github倉庫",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "上記の情報翻訳を利用する(通常は一定の効果が上がるが、遅くなる)",
"文本缓冲区长度": "テキストバッファ長",
- "显示/隐藏历史翻译和调试输出": "履歴翻訳とデバッグ出力の表示/非表示",
"历史翻译和调试输出": "履歴翻訳とデバッグ出力",
"调试输出": "デバッグ出力",
"显示翻译": "翻訳を表示",
diff --git a/LunaTranslator/files/lang/ko.json b/LunaTranslator/files/lang/ko.json
index a5b195cf..73987422 100644
--- a/LunaTranslator/files/lang/ko.json
+++ b/LunaTranslator/files/lang/ko.json
@@ -648,7 +648,6 @@
"Github仓库": "Github 창고",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "위의 정보를 사용하여 번역 (일반적으로 효과가 향상되지만 느려질 수 있음)",
"文本缓冲区长度": "텍스트 버퍼 길이",
- "显示/隐藏历史翻译和调试输出": "히스토리 번역 및 디버그 출력 표시 / 숨기기",
"历史翻译和调试输出": "역사 번역 및 디버그 출력",
"调试输出": "출력 디버그",
"显示翻译": "번역 표시",
diff --git a/LunaTranslator/files/lang/pl.json b/LunaTranslator/files/lang/pl.json
index e15cdd0d..748dc333 100644
--- a/LunaTranslator/files/lang/pl.json
+++ b/LunaTranslator/files/lang/pl.json
@@ -648,7 +648,6 @@
"Github仓库": "Magazyn Github",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "Przetłumacz za pomocą informacji podanych w poprzednim tekście (zwykle z pewną poprawą skuteczności, ale może to prowadzić do wolniejszego tłumaczenia)",
"文本缓冲区长度": "Długość bufora tekstu",
- "显示/隐藏历史翻译和调试输出": "Pokaż/ukryj historyczne tłumaczenie i wyjście debugowania",
"历史翻译和调试输出": "Historiczne tłumaczenie i debugowanie",
"调试输出": "Wyjście debugowania",
"显示翻译": "Wyświetl tłumaczenie",
diff --git a/LunaTranslator/files/lang/ru.json b/LunaTranslator/files/lang/ru.json
index c515efbe..43fe3077 100644
--- a/LunaTranslator/files/lang/ru.json
+++ b/LunaTranslator/files/lang/ru.json
@@ -648,7 +648,6 @@
"Github仓库": "Склад Github",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "Использование вышеприведенного перевода информации (обычно имеет определенный эффект улучшения, но приводит к замедлению)",
"文本缓冲区长度": "Длина буфера текста",
- "显示/隐藏历史翻译和调试输出": "Показать / скрыть исторический перевод и отладочный вывод",
"历史翻译和调试输出": "Исторический перевод и отладка вывода",
"调试输出": "Отладочный вывод",
"显示翻译": "Показать перевод",
diff --git a/LunaTranslator/files/lang/th.json b/LunaTranslator/files/lang/th.json
index 75c2be06..502e83e7 100644
--- a/LunaTranslator/files/lang/th.json
+++ b/LunaTranslator/files/lang/th.json
@@ -648,7 +648,6 @@
"Github仓库": "คลังสินค้า Github",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "ใช้ประโยชน์จากการแปลข้อมูลข้างต้น (มักจะมีผลบางอย่างเพิ่มขึ้น แต่ทำให้ช้าลง)",
"文本缓冲区长度": "ความยาวบัฟเฟอร์ข้อความ",
- "显示/隐藏历史翻译和调试输出": "แสดง / ซ่อนการแปลประวัติและการแก้จุดบกพร่องเอาท์พุท",
"历史翻译和调试输出": "การแปลประวัติและการแก้จุดบกพร่องเอาท์พุท",
"调试输出": "การว่าจ้างเอาท์พุท",
"显示翻译": "แสดงคำแปล",
diff --git a/LunaTranslator/files/lang/tr.json b/LunaTranslator/files/lang/tr.json
index ecb71dc3..f3157ed8 100644
--- a/LunaTranslator/files/lang/tr.json
+++ b/LunaTranslator/files/lang/tr.json
@@ -648,7 +648,6 @@
"Github仓库": "Github deposu",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "Önceki metinde verilen bilgileri kullanarak çevirin (genelde etkinliğinde bazı gelişmelerle, fakat daha yavaş çeviriye yol açabilir)",
"文本缓冲区长度": "Metin buffer uzunluğu",
- "显示/隐藏历史翻译和调试输出": "Tarihi çevirimi ve arızasızlandırma çıkışını göster/gizle",
"历史翻译和调试输出": "Tarihi çeviri ve hata ayıklama çıkışı",
"调试输出": "Hata ayıklama çıkışı",
"显示翻译": "Çeviri göster",
diff --git a/LunaTranslator/files/lang/uk.json b/LunaTranslator/files/lang/uk.json
index 714de15b..c34a0f37 100644
--- a/LunaTranslator/files/lang/uk.json
+++ b/LunaTranslator/files/lang/uk.json
@@ -648,7 +648,6 @@
"Github仓库": "Сховище Github",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "Переклад за допомогою інформації, наданої у попередньому тексті (зазвичай, з деяким покращенням ефективності, але це може призвести до повільнішого перекладу)",
"文本缓冲区长度": "Довжина текстового буфера",
- "显示/隐藏历史翻译和调试输出": "Показувати/сховати історичний переклад і вивід зневаджування",
"历史翻译和调试输出": "Історічний переклад і вивід зневаджування",
"调试输出": "Вивод зневаджування",
"显示翻译": "Показувати переклад",
diff --git a/LunaTranslator/files/lang/vi.json b/LunaTranslator/files/lang/vi.json
index 885d19ef..675fbcb0 100644
--- a/LunaTranslator/files/lang/vi.json
+++ b/LunaTranslator/files/lang/vi.json
@@ -648,7 +648,6 @@
"Github仓库": "Kho Github",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "Sử dụng thông tin trên để dịch (thường có một số hiệu ứng tăng lên, nhưng có thể dẫn đến chậm hơn)",
"文本缓冲区长度": "Chiều dài bộ đệm văn bản",
- "显示/隐藏历史翻译和调试输出": "Hiển thị/ẩn lịch sử dịch và đầu ra gỡ lỗi",
"历史翻译和调试输出": "Lịch sử dịch và gỡ lỗi đầu ra",
"调试输出": "Đầu ra gỡ lỗi",
"显示翻译": "Hiện bản dịch",
diff --git a/LunaTranslator/files/lang/zh.json b/LunaTranslator/files/lang/zh.json
index 847991bd..516588d9 100644
--- a/LunaTranslator/files/lang/zh.json
+++ b/LunaTranslator/files/lang/zh.json
@@ -647,7 +647,6 @@
"Github仓库": "",
"利用上文信息翻译(通常会有一定的效果提升,但会导致变慢)": "",
"文本缓冲区长度": "",
- "显示/隐藏历史翻译和调试输出": "",
"历史翻译和调试输出": "",
"历史翻译": "",
"调试输出": "",
diff --git a/plugins/exec/PyStand.cpp b/plugins/exec/PyStand.cpp
index 97a09e84..0f832243 100644
--- a/plugins/exec/PyStand.cpp
+++ b/plugins/exec/PyStand.cpp
@@ -294,7 +294,7 @@ const auto init_script =
L" sys.stderr = fp\n"
L" attached = False\n"
#endif
- L"sys.argv = [PYSTAND_SCRIPT] + sys.argv[1:]\n"
+ L"sys.argv = [sys.argv[0], PYSTAND_SCRIPT] + sys.argv[1:]\n"
L"text = open(PYSTAND_SCRIPT, 'rb').read()\n"
L"environ = {'__file__': PYSTAND_SCRIPT, '__name__': '__main__'}\n"
L"environ['__package__'] = None\n"