Update vocab for certain files
This commit is contained in:
parent
69fd25e355
commit
0750e7d0cb
1 changed files with 21 additions and 7 deletions
|
|
@ -813,8 +813,9 @@ def translateGeneric(data, filename, translatedDataList=None, pbar=None):
|
||||||
originalMsgCount = len(msgList)
|
originalMsgCount = len(msgList)
|
||||||
originalCommandArrayCount = len(commandArrayList)
|
originalCommandArrayCount = len(commandArrayList)
|
||||||
|
|
||||||
# Keep a copy of original names for vocab update (for characters.json)
|
# Keep a copy of original names for vocab update (for characters/items/skills/classes/weapons)
|
||||||
originalNameList = nameList.copy() if "characters" in filename.lower() else []
|
vocab_name_files = ["characters", "items", "skills", "classes", "weapons"]
|
||||||
|
originalNameList = nameList.copy() if any(tag in filename.lower() for tag in vocab_name_files) else []
|
||||||
|
|
||||||
# Batch translate names
|
# Batch translate names
|
||||||
if nameList:
|
if nameList:
|
||||||
|
|
@ -829,12 +830,25 @@ def translateGeneric(data, filename, translatedDataList=None, pbar=None):
|
||||||
totalTokens[0] += response[1][0]
|
totalTokens[0] += response[1][0]
|
||||||
totalTokens[1] += response[1][1]
|
totalTokens[1] += response[1][1]
|
||||||
|
|
||||||
# Update vocab.txt for characters.json
|
# Update vocab.txt for name-bearing files
|
||||||
if "characters" in filename.lower() and originalNameList and nameList:
|
if originalNameList and nameList:
|
||||||
try:
|
try:
|
||||||
# Create pairs of (original, translated) for vocab
|
file_lower = filename.lower()
|
||||||
vocab_pairs = list(zip(originalNameList, nameList))
|
section = None
|
||||||
update_vocab_section("Speakers", vocab_pairs)
|
if "characters" in file_lower:
|
||||||
|
section = "Speakers"
|
||||||
|
elif "items" in file_lower:
|
||||||
|
section = "Items"
|
||||||
|
elif "skills" in file_lower:
|
||||||
|
section = "Skills"
|
||||||
|
elif "classes" in file_lower:
|
||||||
|
section = "Classes"
|
||||||
|
elif "weapons" in file_lower:
|
||||||
|
section = "Weapons"
|
||||||
|
|
||||||
|
if section:
|
||||||
|
vocab_pairs = list(zip(originalNameList, nameList))
|
||||||
|
update_vocab_section(section, vocab_pairs)
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue