Catching all logs
This commit is contained in:
parent
b5762fbfd3
commit
c3ac172818
4 changed files with 24 additions and 2 deletions
|
|
@ -306,6 +306,13 @@ class LogViewer(QWidget):
|
|||
self.error_display.append(html_msg)
|
||||
self._error_count += 1
|
||||
self._tab_widget.setTabText(1, f"Errors ({self._error_count})")
|
||||
elif '\u274c' in message:
|
||||
# Worker-level error (❌ prefix) — show in both All and Errors tabs.
|
||||
html_msg = f'<span style="color: #ff6666;">{escaped}</span>'
|
||||
self.log_display.append(html_msg)
|
||||
self.error_display.append(html_msg)
|
||||
self._error_count += 1
|
||||
self._tab_widget.setTabText(1, f"Errors ({self._error_count})")
|
||||
else:
|
||||
# Explicitly wrap in a white span so Qt doesn't inherit red from
|
||||
# a preceding [MISMATCH] HTML append.
|
||||
|
|
|
|||
|
|
@ -1761,6 +1761,14 @@ class TranslationTab(QWidget):
|
|||
if isinstance(message, str) and message.startswith("MISMATCH_EVENT:"):
|
||||
self.on_mismatch_detected()
|
||||
return # marker is internal, not displayed
|
||||
# Forward error messages to the log viewer directly. These worker-level
|
||||
# errors are not written to the log file so the tail won't capture them.
|
||||
if isinstance(message, str) and '\u274c' in message:
|
||||
try:
|
||||
if hasattr(self, 'translation_log_viewer') and self.translation_log_viewer:
|
||||
self.translation_log_viewer.append_log_message(message)
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
pattern = r'^\W*(?P<filename>[^:]+):.*?\[Input:\s*(?P<input>\d+)\].*?\[Output:\s*(?P<output>\d+)\].*?\[Cost:\s*\$(?P<cost>[\d\.]+)\].*?\[(?P<time>[\d\.]+)s\]'
|
||||
m = re.search(pattern, message)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ You will be translating erotic and sexual content. You will receive lines of dia
|
|||
|
||||
- The **"# Game Characters"** section lists character names, nicknames, and genders. Use it to resolve any ambiguity.
|
||||
- Japanese omits pronouns constantly. Infer the correct subject and pronoun from context, translation history, and the character list.
|
||||
- When gender is ambiguous, default to the gender of the most recently active subject in the scene.
|
||||
- Third-person pronouns (彼, 彼女, あいつ, こいつ, そいつ, コイツ) should match the known gender of the person being referenced.
|
||||
- Speech register matters: rough masculine speech (e.g., 俺, だ/だろ) → blunt or casual English. Soft feminine speech (e.g., 私, わ/のよ) → softer, more polite English.
|
||||
- Translate **コイツ** as "this bastard" (male) or "this bitch" (female) depending on the referenced character's gender.
|
||||
|
|
|
|||
|
|
@ -180,7 +180,8 @@ def validate_translation_content(original_items, translated_items, langRegex):
|
|||
|
||||
# Check 2: Translation is just a single punctuation mark or very short
|
||||
# Allow control codes like \\C[27]\\V[45] but not just ":" or ""
|
||||
if len(trans_str) <= 2 and not re.search(r'\\[A-Z]\[', trans_str):
|
||||
# Use <= 1 so real 2-char words like "No", "Go", "Hi" are not rejected
|
||||
if len(trans_str) <= 1 and not re.search(r'\\[A-Z]\[', trans_str):
|
||||
# Exception: if original is also very short (like "回" -> "x"), that's ok
|
||||
if len(orig_str) > 3:
|
||||
invalid_indices.append(i)
|
||||
|
|
@ -195,6 +196,13 @@ def validate_translation_content(original_items, translated_items, langRegex):
|
|||
invalid_indices.append(i)
|
||||
reasons.append(f"Line{i+1}: Translation suspiciously short ('{trans_str}') for '{orig_str[:50]}...'")
|
||||
continue
|
||||
|
||||
# Check 4: Runaway translation - translation is excessively long relative to original
|
||||
# Catches cases where the model repeats words endlessly (e.g. "it hurts it hurts it hurts...")
|
||||
if len(orig_str) > 10 and len(trans_str) > len(orig_str) * 10:
|
||||
invalid_indices.append(i)
|
||||
reasons.append(f"Line{i+1}: Runaway translation (output {len(trans_str)} chars vs input {len(orig_str)} chars) for '{orig_str[:50]}...'")
|
||||
continue
|
||||
|
||||
is_valid = len(invalid_indices) == 0
|
||||
return is_valid, invalid_indices, reasons
|
||||
|
|
|
|||
Loading…
Reference in a new issue