3636REPO_ROOT = Path (__file__ ).resolve ().parent .parent
3737WORK_DIR = REPO_ROOT / ".crowdin-translate"
3838BUNDLES_DIR = WORK_DIR / "bundles"
39- DEFAULT_OUTPUT_DIR = WORK_DIR / "translated"
4039ERRORS_DIR = WORK_DIR / "errors"
4140DOMAIN_PROMPT_CACHE_DIR = WORK_DIR / "domain-prompt-cache"
4241
@@ -775,11 +774,13 @@ def on_progress(done: int, total: int) -> None:
775774 f"source={ u .source [:200 ]} \n " )
776775 log .info (" Error details written to %s" , err_path )
777776
777+ new_success = [u for u in translated_units if u .translated ]
778+
778779 if already_done and output_file .exists ():
779780 existing_units = _parse_existing_output (output_file )
780- all_units = existing_units + [ u for u in translated_units if u . translated ]
781+ all_units = existing_units + new_success
781782 else :
782- all_units = [ u for u in translated_units if u . translated ]
783+ all_units = new_success
783784
784785 if not all_units :
785786 if interrupted :
@@ -793,8 +794,10 @@ def on_progress(done: int, total: int) -> None:
793794 output_file .write_text (xliff_content , encoding = "utf-8" )
794795 log .info (" Written: %s (%d units)" , output_file .name , len (all_units ))
795796
796- if not skip_upload and not interrupted :
797+ if not skip_upload and not interrupted and new_success :
797798 upload_xliff (output_file , crowdin_lang )
799+ elif not new_success :
800+ log .info (" No new translations this run, skipping upload" )
798801
799802 if interrupted :
800803 raise KeyboardInterrupt
@@ -872,7 +875,7 @@ def build_parser() -> argparse.ArgumentParser:
872875 p .add_argument ("--skip-upload" , action = "store_true" ,
873876 help = "Skip uploading translations to Crowdin" )
874877 p .add_argument ("--output-dir" , type = Path , default = None ,
875- help = f "Output directory (default: { DEFAULT_OUTPUT_DIR } )" )
878+ help = "Output directory (default: <bundle-dir>/translated/ )" )
876879 p .add_argument ("--include-docs" , action = "store_true" ,
877880 help = "Include /docs/ files in translation (skipped by default)" )
878881 p .add_argument ("-v" , "--verbose" , action = "store_true" ,
@@ -923,8 +926,12 @@ def main() -> None:
923926 else :
924927 bundle_dir = download_bundle (args .bundle_id )
925928
926- output_dir = args .output_dir or DEFAULT_OUTPUT_DIR
929+ if args .output_dir :
930+ output_dir = args .output_dir
931+ else :
932+ output_dir = bundle_dir / "translated"
927933 output_dir .mkdir (parents = True , exist_ok = True )
934+ log .info ("Output directory: %s" , output_dir )
928935
929936 exclude_paths : list [str ] | None = None if args .include_docs else ["/docs/" ]
930937 if exclude_paths :
0 commit comments