| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,13 @@ | |||
| 15 | 15 | passing --no-location --no-wrap and the other not), which otherwise shows | |
| 16 | 16 | up as spurious rewrap-only diffs on whichever path runs next. | |
| 17 | 17 | ||
| 18 | + Note: sphinx.po is NOT part of the CPython Doc/ gettext extraction -- | ||
| 19 | + it tracks Sphinx's own internal UI-string catalog (versionadded, | ||
| 20 | + versionchanged, deprecated, etc.), which ships inside the installed | ||
| 21 | + `sphinx` package itself at sphinx/locale/sphinx.pot. It has its own | ||
| 22 | + fetch/merge path below (sync_sphinx_catalog) so it doesn't silently | ||
| 23 | + fall out of every merge_existing() pass the way it did before. | ||
| 24 | + | ||
| 18 | 25 | This module is a library first, CLI second. As a CLI it exposes just the | |
| 19 | 26 | "mechanical middle" of the sync -- build .pot templates, merge them into | |
| 20 | 27 | existing .po files, flag new upstream pages with no .po yet, validate -- | |
@@ -221,6 +228,44 @@ def merge_all( | |||
| 221 | 228 | return report | |
| 222 | 229 | ||
| 223 | 230 | ||
| 231 | + # --------------------------------------------------------------------------- | ||
| 232 | + # Sphinx's own UI-string catalog (separate from CPython's Doc/ content) | ||
| 233 | + # --------------------------------------------------------------------------- | ||
| 234 | + | ||
| 235 | + | ||
| 236 | + def find_sphinx_pot(venv_dir: Path) -> Path: | ||
| 237 | + """Locate sphinx.pot inside the sphinx version installed in `venv_dir` | ||
| 238 | + (the same venv build_gettext() creates from Doc/requirements.txt, so | ||
| 239 | + this stays pinned to whatever Sphinx version CPython's docs actually | ||
| 240 | + build with -- not whatever sphinx happens to be on the runner).""" | ||
| 241 | + python = venv_dir / "bin" / "python" | ||
| 242 | + result = subprocess.run( | ||
| 243 | + [str(python), "-c", "import sphinx, os; print(os.path.dirname(sphinx.__file__))"], | ||
| 244 | + capture_output=True, | ||
| 245 | + text=True, | ||
| 246 | + check=True, | ||
| 247 | + ) | ||
| 248 | + sphinx_dir = Path(result.stdout.strip()) | ||
| 249 | + pot_path = sphinx_dir / "locale" / "sphinx.pot" | ||
| 250 | + if not pot_path.exists(): | ||
| 251 | + raise FileNotFoundError(f"sphinx.pot not found at {pot_path}") | ||
| 252 | + return pot_path | ||
| 253 | + | ||
| 254 | + | ||
| 255 | + def sync_sphinx_catalog( | ||
| 256 | + doc_venv_dir: Path, repo_root: Path = REPO_ROOT | ||
| 257 | + ) -> bool: | ||
| 258 | + """Merge Sphinx's own sphinx.pot into this repo's top-level sphinx.po. | ||
| 259 | + Returns True if sphinx.po exists and was merged, False if there's no | ||
| 260 | + sphinx.po in this repo to merge into (nothing to do).""" | ||
| 261 | + po_path = repo_root / "sphinx.po" | ||
| 262 | + if not po_path.exists(): | ||
| 263 | + return False | ||
| 264 | + pot_path = find_sphinx_pot(doc_venv_dir) | ||
| 265 | + run(["msgmerge", *MSGMERGE_FLAGS, str(po_path), str(pot_path)]) | ||
| 266 | + return True | ||
| 267 | + | ||
| 268 | + | ||
| 224 | 269 | # --------------------------------------------------------------------------- | |
| 225 | 270 | # Validate | |
| 226 | 271 | # --------------------------------------------------------------------------- | |
@@ -254,6 +299,7 @@ def _cli_sync_only(args: argparse.Namespace) -> int: | |||
| 254 | 299 | via update_python_version.py).""" | |
| 255 | 300 | workdir = REPO_ROOT / ".cpython-src" | |
| 256 | 301 | tag = args.tag | |
| 302 | + doc_venv_dir = workdir / "Doc" / "venv" | ||
| 257 | 303 | ||
| 258 | 304 | print(f"== Sparse-fetching CPython {tag} ==") | |
| 259 | 305 | fetch_cpython_sparse(tag, workdir) | |
@@ -271,6 +317,13 @@ def _cli_sync_only(args: argparse.Namespace) -> int: | |||
| 271 | 317 | for rel in report.new_pot_no_po: | |
| 272 | 318 | print(f" - {rel}") | |
| 273 | 319 | ||
| 320 | + print("\n== Syncing sphinx.po against installed Sphinx's own catalog ==") | ||
| 321 | + synced = sync_sphinx_catalog(doc_venv_dir) | ||
| 322 | + if synced: | ||
| 323 | + print(" sphinx.po merged against sphinx/locale/sphinx.pot") | ||
| 324 | + else: | ||
| 325 | + print(" no top-level sphinx.po found -- skipping") | ||
| 326 | + | ||
| 274 | 327 | print("\n== Validating .po files ==") | |
| 275 | 328 | bad = check_po_files() | |
| 276 | 329 | if bad: | |
@@ -310,4 +363,4 @@ def main() -> None: | |||
| 310 | 363 | ||
| 311 | 364 | ||
| 312 | 365 | if __name__ == "__main__": | |
| 313 | - main() | ||
| 366 | + main() | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -388,3 +388,15 @@ msgstr "" | |||
| 388 | 388 | ||
| 389 | 389 | msgid "the current stable release" | |
| 390 | 390 | msgstr "نسخهی پایدار فعلی" | |
| 391 | + | ||
| 392 | + msgid "Added in version %s" | ||
| 393 | + msgstr "اضافه شده در نسخهی %s" | ||
| 394 | + | ||
| 395 | + msgid "Changed in version %s" | ||
| 396 | + msgstr "تغییر یافته در نسخهی %s" | ||
| 397 | + | ||
| 398 | + msgid "Deprecated since version %s" | ||
| 399 | + msgstr "منسوخ شده از نسخهی %s" | ||
| 400 | + | ||
| 401 | + msgid "Removed in version %s" | ||
| 402 | + msgstr "حذف شده در نسخهی %s" | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments