(
file_path: str, *, check_translation_outdated: bool = True
)
| 403 | |
| 404 | |
| 405 | def translate_single_source_file( |
| 406 | file_path: str, *, check_translation_outdated: bool = True |
| 407 | ) -> None: |
| 408 | relative_path = os.path.relpath(file_path, source_dir) |
| 409 | if "ref/" in relative_path or not file_path.endswith(".md"): |
| 410 | return |
| 411 | if check_translation_outdated and not should_translate_based_on_translation(file_path): |
| 412 | print(f"Skipping {file_path}: The translated one is up-to-date.") |
| 413 | return |
| 414 | |
| 415 | for lang_code in languages: |
| 416 | target_dir = os.path.join(source_dir, lang_code) |
| 417 | target_path = os.path.join(target_dir, relative_path) |
| 418 | |
| 419 | # Ensure the target directory exists |
| 420 | os.makedirs(os.path.dirname(target_path), exist_ok=True) |
| 421 | |
| 422 | # Translate and save the file |
| 423 | translate_file(file_path, target_path, lang_code) |
| 424 | |
| 425 | |
| 426 | def normalize_source_file_arg(file_arg: str) -> str: |
no test coverage detected