mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
refactor: optimize translation unit handling in Crowdin script
- Introduced a new variable to track successfully translated units, improving clarity and efficiency in the processing logic. - Updated the logic for combining existing and new translation units, ensuring accurate output and preventing unnecessary uploads when no new translations are available.
This commit is contained in:
parent
756bc1e11f
commit
7ec9d64b5b
1 changed files with 7 additions and 3 deletions
|
|
@ -775,11 +775,13 @@ def process_language(
|
||||||
f"source={u.source[:200]}\n")
|
f"source={u.source[:200]}\n")
|
||||||
log.info(" Error details written to %s", err_path)
|
log.info(" Error details written to %s", err_path)
|
||||||
|
|
||||||
|
new_success = [u for u in translated_units if u.translated]
|
||||||
|
|
||||||
if already_done and output_file.exists():
|
if already_done and output_file.exists():
|
||||||
existing_units = _parse_existing_output(output_file)
|
existing_units = _parse_existing_output(output_file)
|
||||||
all_units = existing_units + [u for u in translated_units if u.translated]
|
all_units = existing_units + new_success
|
||||||
else:
|
else:
|
||||||
all_units = [u for u in translated_units if u.translated]
|
all_units = new_success
|
||||||
|
|
||||||
if not all_units:
|
if not all_units:
|
||||||
if interrupted:
|
if interrupted:
|
||||||
|
|
@ -793,8 +795,10 @@ def process_language(
|
||||||
output_file.write_text(xliff_content, encoding="utf-8")
|
output_file.write_text(xliff_content, encoding="utf-8")
|
||||||
log.info(" Written: %s (%d units)", output_file.name, len(all_units))
|
log.info(" Written: %s (%d units)", output_file.name, len(all_units))
|
||||||
|
|
||||||
if not skip_upload and not interrupted:
|
if not skip_upload and not interrupted and new_success:
|
||||||
upload_xliff(output_file, crowdin_lang)
|
upload_xliff(output_file, crowdin_lang)
|
||||||
|
elif not new_success:
|
||||||
|
log.info(" No new translations this run, skipping upload")
|
||||||
|
|
||||||
if interrupted:
|
if interrupted:
|
||||||
raise KeyboardInterrupt
|
raise KeyboardInterrupt
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue