More fixes
This commit is contained in:
parent
f9b4e95c9a
commit
23b4b97bda
2 changed files with 26 additions and 19 deletions
|
|
@ -2045,11 +2045,6 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
nametag = nametag.replace(speaker, tledSpeaker)
|
||||
speaker = tledSpeaker
|
||||
|
||||
# Detect pure-ellipsis strings (e.g. 「………」) before any transformation.
|
||||
# These are passed through as-is after bracket conversion, not sent to AI.
|
||||
_ell_inner = finalJAString.strip().lstrip('「').rstrip('」').strip()
|
||||
isEllipsisOnly = bool(_ell_inner) and all(c == '\u2026' for c in _ell_inner)
|
||||
|
||||
# Remove Extra Stuff bad for translation.
|
||||
finalJAString = finalJAString.replace("゙", "")
|
||||
finalJAString = finalJAString.replace(" ", "")
|
||||
|
|
@ -2112,7 +2107,7 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
finalJAString = finalJAString.replace("\\px[200]", "")
|
||||
|
||||
# Append
|
||||
if finalJAString != "" and not isEllipsisOnly:
|
||||
if finalJAString != "":
|
||||
if speaker == "" and finalJAString != "":
|
||||
list401.append(finalJAString)
|
||||
elif finalJAString != "":
|
||||
|
|
@ -2132,19 +2127,8 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
|
||||
# Pass 2 (Setting Data)
|
||||
else:
|
||||
# Ellipsis-only: bypass AI, set cleaned string directly
|
||||
if isEllipsisOnly:
|
||||
translatedText = nametag + finalJAString
|
||||
nametag = ""
|
||||
codeList[j]["code"] = code
|
||||
codeList[j]["parameters"] = [translatedText]
|
||||
syncIndex = i + 1
|
||||
speaker = ""
|
||||
match = []
|
||||
currentGroup = []
|
||||
|
||||
# Grab Translated String
|
||||
elif len(list401) > 0:
|
||||
if len(list401) > 0:
|
||||
translatedText = list401[0]
|
||||
|
||||
# Remove speaker prefix if present
|
||||
|
|
@ -3342,7 +3326,8 @@ def searchCodes(page, pbar, jobList, filename):
|
|||
|
||||
# Cant have spaces?
|
||||
translatedText = translatedText.replace(" ", "_")
|
||||
translatedText = translatedText.replace("__", "_")
|
||||
if "D_TEXT " not in jaString:
|
||||
translatedText = translatedText.replace("__", "_")
|
||||
|
||||
# Put Args Back
|
||||
translatedText = jaString.replace(text, translatedText)
|
||||
|
|
|
|||
|
|
@ -1395,6 +1395,28 @@ def translateAI(text, history, config, filename=None, pbar=None, lock=None, mism
|
|||
history = tItem[-config.maxHistory:] if isinstance(tItem, list) else tItem
|
||||
continue
|
||||
|
||||
# Ellipsis-only bypass: strings whose translatable content is purely '…' characters
|
||||
# (e.g. "「………」") should never be sent to the AI — just convert brackets and pass through.
|
||||
def _is_ellipsis_only(s):
|
||||
inner = str(s).strip().lstrip('「').rstrip('」').strip()
|
||||
return bool(inner) and all(c == '\u2026' for c in inner)
|
||||
|
||||
def _convert_ellipsis(s):
|
||||
return str(s).replace('「', '"').replace('」', '"')
|
||||
|
||||
if isinstance(tItem, list):
|
||||
if all(_is_ellipsis_only(s) for s in tItem):
|
||||
tList[index] = [_convert_ellipsis(s) for s in tItem]
|
||||
if pbar is not None:
|
||||
pbar.update(len(tItem))
|
||||
continue
|
||||
else:
|
||||
if _is_ellipsis_only(tItem):
|
||||
tList[index] = _convert_ellipsis(tItem)
|
||||
if pbar is not None:
|
||||
pbar.update(1)
|
||||
continue
|
||||
|
||||
# Protect script codes before translation
|
||||
protected_items = []
|
||||
all_replacements = {}
|
||||
|
|
|
|||
Loading…
Reference in a new issue