mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-29 16:44:13 +08:00
fix
This commit is contained in:
parent
37c76dedc6
commit
416c52971e
@ -126,6 +126,7 @@ class MAINUI:
|
|||||||
|
|
||||||
def solvebeforetrans(self, content):
|
def solvebeforetrans(self, content):
|
||||||
contexts = []
|
contexts = []
|
||||||
|
self.zhanweifu = 0
|
||||||
for i in range(len(self.processmethods)):
|
for i in range(len(self.processmethods)):
|
||||||
try:
|
try:
|
||||||
if self.processmethods[i].using:
|
if self.processmethods[i].using:
|
||||||
|
@ -2,6 +2,8 @@ from myutils.config import globalconfig
|
|||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
import os, gobject, re
|
import os, gobject, re
|
||||||
|
|
||||||
|
___idx = 1
|
||||||
|
|
||||||
|
|
||||||
def vnrshareddict(self):
|
def vnrshareddict(self):
|
||||||
|
|
||||||
@ -102,6 +104,7 @@ class Process:
|
|||||||
vnrshareddict(self)
|
vnrshareddict(self)
|
||||||
|
|
||||||
def process_before(self, content):
|
def process_before(self, content):
|
||||||
|
___idx = 1
|
||||||
self.checkchange()
|
self.checkchange()
|
||||||
context = {}
|
context = {}
|
||||||
|
|
||||||
@ -116,7 +119,12 @@ class Process:
|
|||||||
# if self.vnrshareddict[key]['src']==self.vnrshareddict[key]['tgt']:
|
# if self.vnrshareddict[key]['src']==self.vnrshareddict[key]['tgt']:
|
||||||
# content=content.replace(key,self.vnrshareddict[key]['text'])
|
# content=content.replace(key,self.vnrshareddict[key]['text'])
|
||||||
# else:
|
# else:
|
||||||
|
if ___idx == 1:
|
||||||
|
xx = "ZX{}Z".format(chr(ord("B") + gobject.baseobject.zhanweifu))
|
||||||
|
elif ___idx == 2:
|
||||||
xx = "{{{}}}".format(gobject.baseobject.zhanweifu)
|
xx = "{{{}}}".format(gobject.baseobject.zhanweifu)
|
||||||
|
elif ___idx == 3:
|
||||||
|
xx = key
|
||||||
content = content.replace(key, xx)
|
content = content.replace(key, xx)
|
||||||
context[xx] = key
|
context[xx] = key
|
||||||
gobject.baseobject.zhanweifu += 1
|
gobject.baseobject.zhanweifu += 1
|
||||||
|
@ -2,44 +2,40 @@ from myutils.config import noundictconfig
|
|||||||
import gobject, re
|
import gobject, re
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Process:
|
class Process:
|
||||||
|
|
||||||
def process_before(self, content):
|
def process_before(self, content):
|
||||||
|
___idx = 1
|
||||||
mp1 = {}
|
mp1 = {}
|
||||||
for key in noundictconfig["dict"]:
|
for key in noundictconfig["dict"]:
|
||||||
usedict = False
|
v = None
|
||||||
if type(noundictconfig["dict"][key]) == str:
|
if type(noundictconfig["dict"][key]) == str:
|
||||||
usedict = True
|
v = noundictconfig["dict"][mp1[key]]
|
||||||
else:
|
else:
|
||||||
for i in range(len(noundictconfig["dict"][key]) // 2):
|
for i in range(len(noundictconfig["dict"][key]) // 2):
|
||||||
if noundictconfig["dict"][key][i * 2] in [
|
if noundictconfig["dict"][key][i * 2] in [
|
||||||
"0",
|
"0",
|
||||||
gobject.baseobject.currentmd5,
|
gobject.baseobject.currentmd5,
|
||||||
]:
|
]:
|
||||||
usedict = True
|
v = noundictconfig["dict"][key][i * 2 + 1]
|
||||||
break
|
break
|
||||||
|
|
||||||
if usedict and key in content:
|
if v is not None and key in content:
|
||||||
|
if ___idx == 1:
|
||||||
|
xx = "ZX{}Z".format(chr(ord("B") + gobject.baseobject.zhanweifu))
|
||||||
|
elif ___idx == 2:
|
||||||
xx = "{{{}}}".format(gobject.baseobject.zhanweifu)
|
xx = "{{{}}}".format(gobject.baseobject.zhanweifu)
|
||||||
|
elif ___idx == 3:
|
||||||
|
xx = v
|
||||||
content = content.replace(key, xx)
|
content = content.replace(key, xx)
|
||||||
mp1[xx] = key
|
mp1[xx] = v
|
||||||
gobject.baseobject.zhanweifu += 1
|
gobject.baseobject.zhanweifu += 1
|
||||||
return content, mp1
|
return content, mp1
|
||||||
|
|
||||||
def process_after(self, res, mp1):
|
def process_after(self, res, mp1):
|
||||||
for key in mp1:
|
for key in mp1:
|
||||||
reg = re.compile(re.escape(key), re.IGNORECASE)
|
reg = re.compile(re.escape(key), re.IGNORECASE)
|
||||||
if type(noundictconfig["dict"][mp1[key]]) == str:
|
res = reg.sub(mp1[key], res)
|
||||||
v = noundictconfig["dict"][mp1[key]]
|
|
||||||
elif type(noundictconfig["dict"][mp1[key]]) == list:
|
|
||||||
v = ""
|
|
||||||
for i in range(len(noundictconfig["dict"][mp1[key]]) // 2):
|
|
||||||
if noundictconfig["dict"][mp1[key]][i * 2] in [
|
|
||||||
"0",
|
|
||||||
gobject.baseobject.currentmd5,
|
|
||||||
]:
|
|
||||||
v = noundictconfig["dict"][mp1[key]][i * 2 + 1]
|
|
||||||
break
|
|
||||||
res = reg.sub(v, res)
|
|
||||||
return res
|
return res
|
||||||
|
Loading…
x
Reference in New Issue
Block a user