MCPcopy Create free account
hub / github.com/openai/openai-agents-python / translate_single_source_file

Function translate_single_source_file

docs/scripts/translate_docs.py:405–423  ·  view source on GitHub ↗
(
    file_path: str, *, check_translation_outdated: bool = True
)

Source from the content-addressed store, hash-verified

403
404
405def 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
426def normalize_source_file_arg(file_arg: str) -> str:

Callers 1

translate_source_filesFunction · 0.85

Calls 3

translate_fileFunction · 0.85
relpathMethod · 0.80

Tested by

no test coverage detected