Skip to content

Commit ae2d70c

Browse files
authored
Update translation_status script and CONTRIBUTING.md
2 parents 6346929 + 93d2f32 commit ae2d70c

2 files changed

Lines changed: 23 additions & 11 deletions

File tree

CONTRIBUTING.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,6 @@ python3 scripts/update_python_version.py v3.15.0 --keep-src
107107

108108
این اسکریپت نسخهٔ مشخص‌شدهٔ CPython را کلون می‌کند، قالب‌های gettext (`*.pot`) را از روی آن می‌سازد، فایل‌های `.po` موجود را با `msgmerge` به‌روزرسانی می‌کند، برای صفحات جدید فایل `.po` تازه می‌سازد و در پایان همهٔ فایل‌ها را با `msgfmt --check` صحت‌سنجی می‌کند. بعد از اجرای آن، خروجی را بازبینی کنید و اعتبارهای سربرگ را (در صورت نیاز با `scripts/update_po_headers.py`) به‌روزرسانی کنید.
109109

110-
## اولویت‌ها
111-
112-
اگر تازه‌کار هستید، اول روی فایل‌هایی تمرکز کنید که برای قرار گرفتن فارسی در «تغییردهندهٔ زبان» (language switcher) مستندات پایتون لازم‌اند:
113-
114-
- `bugs.po`
115-
- همهٔ فایل‌های `tutorial/`
116-
- `library/functions.po`
110+
## مقدار ترجمه‌ی باقی‌مانده
117111

118112
با `python3 scripts/translation_status.py --only-incomplete` می‌توانید وضعیت دقیق هر فایل را ببینید.

scripts/translation_status.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,31 @@ def file_stats(path: Path):
3131
)
3232

3333

34-
def collect_files(paths):
34+
def collect_files(paths, exclude=None):
35+
exclude = {Path(e).resolve() for e in (exclude or [])}
3536
files = []
37+
38+
def is_excluded(path):
39+
resolved = path.resolve()
40+
return resolved in exclude or any(
41+
parent in exclude for parent in resolved.parents
42+
)
43+
3644
for arg in paths:
3745
p = Path(arg)
3846
if p.is_dir():
47+
if is_excluded(p):
48+
continue
3949
for f in p.rglob("*.po"):
4050
if any(part.startswith(".") for part in f.parts):
4151
continue
52+
if is_excluded(f):
53+
continue
4254
files.append(f)
4355
elif p.suffix == ".po":
44-
files.append(p)
56+
if not is_excluded(p):
57+
files.append(p)
58+
4559
return files
4660

4761

@@ -66,10 +80,14 @@ def main():
6680
action="store_true",
6781
help="Hide files that are already fully translated",
6882
)
83+
parser.add_argument(
84+
"--exclude",
85+
nargs="*",
86+
help="Exclude files or directories from scan",
87+
)
6988
parser.add_argument("--format", choices=["text", "markdown", "csv"], default="text")
7089
args = parser.parse_args()
71-
72-
files = collect_files(args.paths)
90+
files = collect_files(args.paths, args.exclude)
7391
if not files:
7492
print("No .po files found.")
7593
sys.exit(1)

0 commit comments

Comments
 (0)