MCPcopy Create free account
hub / github.com/fastapi/fastapi / translate_lang

Function translate_lang

scripts/translate.py:214–239  ·  view source on GitHub ↗
(language: Annotated[str, typer.Option(envvar="LANGUAGE")])

Source from the content-addressed store, hash-verified

212
213@app.command()
214def translate_lang(language: Annotated[str, typer.Option(envvar="LANGUAGE")]) -> None:
215 paths_to_process = list(iter_en_paths_to_translate())
216 print("Original paths:")
217 for p in paths_to_process:
218 print(f" - {p}")
219 print(f"Total original paths: {len(paths_to_process)}")
220 missing_paths: list[Path] = []
221 skipped_paths: list[Path] = []
222 for p in paths_to_process:
223 lang_path = generate_lang_path(lang=language, path=p)
224 if lang_path.exists():
225 skipped_paths.append(p)
226 continue
227 missing_paths.append(p)
228 print("Paths to skip:")
229 for p in skipped_paths:
230 print(f" - {p}")
231 print(f"Total paths to skip: {len(skipped_paths)}")
232 print("Paths to process:")
233 for p in missing_paths:
234 print(f" - {p}")
235 print(f"Total paths to process: {len(missing_paths)}")
236 for p in missing_paths:
237 print(f"Translating: {p}")
238 translate_page(language="es", en_path=p)
239 print(f"Done translating: {p}")
240
241
242def get_llm_translatable() -> list[str]:

Callers

nothing calls this directly

Calls 3

generate_lang_pathFunction · 0.85
translate_pageFunction · 0.85

Tested by

no test coverage detected