Files
local-translator/local_translator/naninovel.py
T
mrleo1nidandClaude Sonnet 5.5 f49ee90477 feat: browser access (allowed_origins, CORS with Private Network Access), job cancel, Tomie/Unity adapters, benchmark
Includes earlier uncommitted work: Tomie and Unity adapters, benchmark, structured output, call metrics.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-25 18:59:28 +03:00

18 lines
662 B
Python

"""Naninovel managed-text dictionary helpers."""
def parse_dictionary(text):
result, seen = [], set()
for line_number, line in enumerate(text.splitlines(), 1):
if not line.strip() or line.lstrip().startswith((";", "#", "//")):
continue
key, separator, value = line.partition(":")
if not separator or not key.strip() or not value.strip():
continue
key = key.strip()
if key in seen:
raise ValueError(f"Duplicate dictionary key at line {line_number}: {key}")
seen.add(key)
result.append({"id": key, "text": value.lstrip(), "line": line_number})
return result