Skip to content

Commit

Permalink
Fix TLK batch translate, add build task
Browse files Browse the repository at this point in the history
  • Loading branch information
th3w1zard1 committed Nov 8, 2023
1 parent e67b6e8 commit afb343d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
17 changes: 17 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,23 @@
],
"problemMatcher": []
},
{
"label": "Build K-BatchPatcher",
"type": "shell",
"dependsOn": ["requirements.txt", "install_pyinstaller"],
"command": "${command:python.interpreterPath}",
"args": [
"-m",
"PyInstaller",
"--console",
"--onefile",
"--clean",
"--name=K_BatchPatcher",
"--path=${workspaceFolder}",
"scripts${pathSeparator}k_batchpatcher${pathSeparator}__main__.py"
],
"problemMatcher": []
},
{
"label": "Build GUI Creator",
"type": "shell",
Expand Down
6 changes: 4 additions & 2 deletions scripts/k_batchpatcher/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,14 @@ def handle_restype_and_patch(

from_lang = tlk.language
if pytranslator is not None:
for _strref, tlkentry in tlk:
new_entries = deepcopy(tlk.entries)
for strref, tlkentry in tlk:
text = tlkentry.text
log_output_with_separator(f"Translating TLK text at {file_path!s}", above=True)
translated_text = pytranslator.translate(text, from_lang=from_lang)
log_output(f"Translated {text} --> {translated_text}")
tlkentry.text = text
new_entries[strref].text = text
tlk.entries = new_entries
write_tlk(tlk, file_path)
if ext in gff_types:
gff: GFF | None = None
Expand Down

0 comments on commit afb343d

Please sign in to comment.