]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
🔨 Add max pages to translate to configs (#14840)
authorSebastián Ramírez <tiangolo@gmail.com>
Thu, 5 Feb 2026 19:25:49 +0000 (11:25 -0800)
committerGitHub <noreply@github.com>
Thu, 5 Feb 2026 19:25:49 +0000 (19:25 +0000)
.github/workflows/translate.yml
scripts/translate.py

index 83518614b02ce000057ed29e012fe736d781a39c..bb23fa32d973a96309add95a98cc8d03b2444a4d 100644 (file)
@@ -35,6 +35,11 @@ on:
         type: boolean
         required: false
         default: false
+      max:
+        description: Maximum number of items to translate (e.g. 10)
+        type: number
+        required: false
+        default: 10
 
 jobs:
   langs:
@@ -115,3 +120,4 @@ jobs:
           EN_PATH: ${{ github.event.inputs.en_path }}
           COMMAND: ${{ matrix.command }}
           COMMIT_IN_PLACE: ${{ github.event.inputs.commit_in_place }}
+          MAX: ${{ github.event.inputs.max }}
index 31c44583d1915aa71be40c43ca520d4e00aad50a..ddcfa311d66ce5a7358eee81cb820fbb45862962 100644 (file)
@@ -347,9 +347,12 @@ def list_outdated(language: str) -> list[Path]:
 
 
 @app.command()
-def update_outdated(language: Annotated[str, typer.Option(envvar="LANGUAGE")]) -> None:
+def update_outdated(
+    language: Annotated[str, typer.Option(envvar="LANGUAGE")],
+    max: Annotated[int, typer.Option(envvar="MAX")] = 10,
+) -> None:
     outdated_paths = list_outdated(language)
-    for path in outdated_paths:
+    for path in outdated_paths[:max]:
         print(f"Updating lang: {language} path: {path}")
         translate_page(language=language, en_path=path)
         print(f"Done updating: {path}")
@@ -357,9 +360,12 @@ def update_outdated(language: Annotated[str, typer.Option(envvar="LANGUAGE")]) -
 
 
 @app.command()
-def add_missing(language: Annotated[str, typer.Option(envvar="LANGUAGE")]) -> None:
+def add_missing(
+    language: Annotated[str, typer.Option(envvar="LANGUAGE")],
+    max: Annotated[int, typer.Option(envvar="MAX")] = 10,
+) -> None:
     missing_paths = list_missing(language)
-    for path in missing_paths:
+    for path in missing_paths[:max]:
         print(f"Adding lang: {language} path: {path}")
         translate_page(language=language, en_path=path)
         print(f"Done adding: {path}")
@@ -367,11 +373,14 @@ def add_missing(language: Annotated[str, typer.Option(envvar="LANGUAGE")]) -> No
 
 
 @app.command()
-def update_and_add(language: Annotated[str, typer.Option(envvar="LANGUAGE")]) -> None:
+def update_and_add(
+    language: Annotated[str, typer.Option(envvar="LANGUAGE")],
+    max: Annotated[int, typer.Option(envvar="MAX")] = 10,
+) -> None:
     print(f"Updating outdated translations for {language}")
-    update_outdated(language=language)
+    update_outdated(language=language, max=max)
     print(f"Adding missing translations for {language}")
-    add_missing(language=language)
+    add_missing(language=language, max=max)
     print(f"Done updating and adding for {language}")