From 93d2f32590fd3105c93e25f1c4efee9c5ad08a42 Mon Sep 17 00:00:00 2001 From: Sepehr Rasouli Date: Sat, 15 Aug 2026 13:30:47 +0330 Subject: [PATCH] Update translation_status script and CONTRIBUTING.md --- CONTRIBUTING.md | 8 +------- scripts/translation_status.py | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a25a42d22..952a603f8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -107,12 +107,6 @@ python3 scripts/update_python_version.py v3.15.0 --keep-src این اسکریپت نسخهٔ مشخص‌شدهٔ CPython را کلون می‌کند، قالب‌های gettext (`*.pot`) را از روی آن می‌سازد، فایل‌های `.po` موجود را با `msgmerge` به‌روزرسانی می‌کند، برای صفحات جدید فایل `.po` تازه می‌سازد و در پایان همهٔ فایل‌ها را با `msgfmt --check` صحت‌سنجی می‌کند. بعد از اجرای آن، خروجی را بازبینی کنید و اعتبارهای سربرگ را (در صورت نیاز با `scripts/update_po_headers.py`) به‌روزرسانی کنید. -## اولویت‌ها - -اگر تازه‌کار هستید، اول روی فایل‌هایی تمرکز کنید که برای قرار گرفتن فارسی در «تغییردهندهٔ زبان» (language switcher) مستندات پایتون لازم‌اند: - -- `bugs.po` -- همهٔ فایل‌های `tutorial/` -- `library/functions.po` +## مقدار ترجمه‌ی باقی‌مانده با `python3 scripts/translation_status.py --only-incomplete` می‌توانید وضعیت دقیق هر فایل را ببینید. diff --git a/scripts/translation_status.py b/scripts/translation_status.py index e06a2d3b9..154b37b41 100644 --- a/scripts/translation_status.py +++ b/scripts/translation_status.py @@ -31,17 +31,31 @@ def file_stats(path: Path): ) -def collect_files(paths): +def collect_files(paths, exclude=None): + exclude = {Path(e).resolve() for e in (exclude or [])} files = [] + + def is_excluded(path): + resolved = path.resolve() + return resolved in exclude or any( + parent in exclude for parent in resolved.parents + ) + for arg in paths: p = Path(arg) if p.is_dir(): + if is_excluded(p): + continue for f in p.rglob("*.po"): if any(part.startswith(".") for part in f.parts): continue + if is_excluded(f): + continue files.append(f) elif p.suffix == ".po": - files.append(p) + if not is_excluded(p): + files.append(p) + return files @@ -66,10 +80,14 @@ def main(): action="store_true", help="Hide files that are already fully translated", ) + parser.add_argument( + "--exclude", + nargs="*", + help="Exclude files or directories from scan", + ) parser.add_argument("--format", choices=["text", "markdown", "csv"], default="text") args = parser.parse_args() - - files = collect_files(args.paths) + files = collect_files(args.paths, args.exclude) if not files: print("No .po files found.") sys.exit(1)