Skip to content

Commit 7ab2f11

Browse files
authored
Update workflows and fix translations
Added a workflow to automatically detect changes to the source strings in `master`, sync translations, mark modified strings as fuzzy, and create an issue for them so they could be reviewed and updated as soon as possible. Additionally, fixed two translation issues that were causing the Persian translation to be skipped.
2 parents 0aba0e3 + ba62f9a commit 7ab2f11

537 files changed

Lines changed: 36398 additions & 108975 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-and-deploy.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,21 @@ jobs:
4040
uses: actions/checkout@v4
4141
with:
4242
path: Doc/locales/fa/LC_MESSAGES
43-
43+
44+
- name: Install gettext
45+
run: sudo apt-get install -y gettext
46+
47+
- name: Compile .po files to .mo
48+
run: |
49+
find Doc/locales/fa/LC_MESSAGES -name "*.po" | while read f; do
50+
msgfmt "$f" -o "${f%.po}.mo"
51+
done
52+
4453
- name: Setup problem matcher
4554
uses: sphinx-doc/github-problem-matcher@v1.1
4655

4756
- name: Build documentation
48-
run: make -e SPHINXOPTS="--color -D language='fa' -D gettext_allow_fuzzy_translations=1 -W --keep-going" html
57+
run: make -e SPHINXOPTS="--color -D language='fa' -D gettext_allow_fuzzy_translations=1 --keep-going" html
4958
working-directory: ./Doc
5059

5160
- name: Setup Pages
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
name: Sync with CPython
2+
3+
on:
4+
schedule:
5+
- cron: '0 4 * * *'
6+
workflow_dispatch:
7+
inputs:
8+
cpython_tag:
9+
description: 'CPython tag to sync against (e.g. v3.14.6)'
10+
required: false
11+
default: 'v3.14.6'
12+
13+
permissions:
14+
contents: write
15+
issues: write
16+
17+
concurrency:
18+
group: sync
19+
cancel-in-progress: false
20+
21+
jobs:
22+
sync:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout translation repo
26+
uses: actions/checkout@v4
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v4
32+
with:
33+
python-version: '3.12'
34+
35+
- name: Install gettext
36+
run: sudo apt-get install -y gettext
37+
38+
- name: Install Python dependencies
39+
run: pip install sphinx sphinx-intl
40+
41+
- name: Checkout CPython docs only (sparse)
42+
run: |
43+
git clone \
44+
--depth 1 \
45+
--filter=blob:none \
46+
--sparse \
47+
--branch ${{ github.event.inputs.cpython_tag || 'v3.14.6' }} \
48+
https://github.com/python/cpython.git \
49+
.cpython-src
50+
cd .cpython-src
51+
git sparse-checkout set Doc Include
52+
53+
- name: Install CPython doc dependencies
54+
run: |
55+
python -m venv .cpython-src/Doc/venv
56+
.cpython-src/Doc/venv/bin/pip install \
57+
-r .cpython-src/Doc/requirements.txt
58+
59+
- name: Build .pot templates
60+
run: |
61+
cd .cpython-src/Doc
62+
./venv/bin/sphinx-build \
63+
-b gettext \
64+
. \
65+
../../.pot-templates
66+
67+
- name: Merge .pot into .po files
68+
run: |
69+
find .pot-templates -name "*.pot" | while read f; do
70+
rel="${f#.pot-templates/}"
71+
po="${rel%.pot}.po"
72+
if [ -f "$po" ]; then
73+
msgmerge --update --backup=off --no-location "$po" "$f"
74+
fi
75+
done
76+
77+
- name: Ensure translation label exists
78+
env:
79+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
80+
run: |
81+
gh label create "translation" \
82+
--color "0075ca" \
83+
--description "Translation review needed" \
84+
--repo ${{ github.repository }} \
85+
2>/dev/null || true
86+
87+
- name: Open issue for fuzzy strings
88+
env:
89+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
90+
CPYTHON_TAG: ${{ github.event.inputs.cpython_tag || 'v3.14.6' }}
91+
run: |
92+
tmpfile=$(mktemp)
93+
while IFS= read -r f; do
94+
fuzzy=$(msgattrib --only-fuzzy --no-obsolete "$f" 2>/dev/null)
95+
if [ -n "$fuzzy" ]; then
96+
entries=$(echo "$fuzzy" | awk '
97+
/^msgid / {
98+
first=$0; msg=$0"\n"; lines=1; incapture=1; next
99+
}
100+
incapture && /^"/ {
101+
msg = msg $0 "\n"; lines++; next
102+
}
103+
incapture && /^msgstr/ {
104+
incapture=0
105+
if (!(first == "msgid \"\"" && lines==1)) {
106+
printf "- %s\n", msg
107+
}
108+
next
109+
}
110+
')
111+
count=$(echo "$entries" | grep -c '^- ' || echo 0)
112+
if [ "$count" -gt 0 ]; then
113+
echo "### $f ($count fuzzy)" >> "$tmpfile"
114+
echo "$entries" | head -20 >> "$tmpfile"
115+
echo "" >> "$tmpfile"
116+
fi
117+
fi
118+
done < <(find . -name "*.po" \
119+
-not -path "./.git/*" \
120+
-not -path "./.cpython-src/*" \
121+
-not -path "./.pot-templates/*")
122+
if [ -s "$tmpfile" ]; then
123+
gh issue create \
124+
--title "🔍 Fuzzy strings need review after CPython sync ($(date +%Y-%m-%d))" \
125+
--body "$(cat "$tmpfile")
126+
127+
Triggered by sync with \`$CPYTHON_TAG\`." \
128+
--label "translation" \
129+
--repo ${{ github.repository }}
130+
fi
131+
rm -f "$tmpfile"
132+
133+
- name: Validate .po files
134+
run: |
135+
tmpfile=$(mktemp)
136+
find . -name "*.po" \
137+
-not -path "./.git/*" \
138+
-not -path "./.cpython-src/*" \
139+
-not -path "./.pot-templates/*" | while read f; do
140+
msgfmt --check "$f" -o /dev/null || echo "FAIL: $f" >> "$tmpfile"
141+
done
142+
if [ -s "$tmpfile" ]; then
143+
cat "$tmpfile"
144+
rm -f "$tmpfile"
145+
exit 1
146+
fi
147+
rm -f "$tmpfile"
148+
149+
- name: Clean up scratch files
150+
run: rm -rf .cpython-src .pot-templates
151+
152+
- name: Commit if changed
153+
run: |
154+
git config user.name "github-actions[bot]"
155+
git config user.email "github-actions[bot]@users.noreply.github.com"
156+
git add --all
157+
git diff --staged -U0 \
158+
| grep '^[+-]' \
159+
| grep -v '^[+-][+-][+-]' \
160+
| grep -qv 'POT-Creation-Date' \
161+
|| { echo "Only POT-Creation-Date changed, skipping commit."; exit 0; }
162+
git commit -m \
163+
"chore: sync msgids with CPython ${{ github.event.inputs.cpython_tag || 'v3.14.6' }}"
164+
git push

about.po

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,19 @@ msgid ""
1414
msgstr ""
1515
"Project-Id-Version: Python 3.14\n"
1616
"Report-Msgid-Bugs-To: \n"
17-
"POT-Creation-Date: 2026-07-25 12:59+0330\n"
17+
"POT-Creation-Date: 2026-08-16 08:01+0000\n"
1818
"PO-Revision-Date: 2021-06-28 00:47+0000\n"
1919
"Last-Translator: Sepehr Rasouli <sepehrrasouli06@gmail.com>, 2026\n"
20-
"Language-Team: Persian (https://github.com/revisto/python-docs-fa/"
21-
"fa/)\n"
20+
"Language-Team: Persian (https://github.com/revisto/python-docs-fa/fa/)\n"
2221
"Language: fa\n"
2322
"MIME-Version: 1.0\n"
2423
"Content-Type: text/plain; charset=UTF-8\n"
2524
"Content-Transfer-Encoding: 8bit\n"
2625
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
2726

28-
#: ../../about.rst:3
2927
msgid "About this documentation"
3028
msgstr "دربارهٔ این مستندات"
3129

32-
#: ../../about.rst:6
3330
msgid ""
3431
"Python's documentation is generated from `reStructuredText`_ sources using "
3532
"`Sphinx`_, a documentation generator originally created for Python and now "
@@ -39,61 +36,53 @@ msgstr ""
3936
"تولید می‌شوند، که یک تولیدکننده مستندات است که در ابتدا برای پایتون ساخته شد "
4037
"و اکنون به‌عنوان یک پروژه مستقل نگهداری می‌شود."
4138

42-
#: ../../about.rst:16
4339
msgid ""
4440
"Development of the documentation and its toolchain is an entirely volunteer "
4541
"effort, just like Python itself. If you want to contribute, please take a "
4642
"look at the :ref:`reporting-bugs` page for information on how to do so. New "
4743
"volunteers are always welcome!"
4844
msgstr ""
4945
"توسعهٔ مستندات و زنجیرهٔ ابزارهایش، همانند خود پایتون تلاشی کاملاً داوطلبانه "
50-
"است. اگر می‌خواهید مشارکت کنید برای اطّلاعات در مورد چگونگی آن نگاهی به "
51-
"صفحهٔ :ref:`reporting-bugs` بیندازید. همیشه از داوطلبان جدید استقبال می‌شود!"
46+
"است. اگر می‌خواهید مشارکت کنید برای اطّلاعات در مورد چگونگی آن نگاهی به صفحهٔ :"
47+
"ref:`reporting-bugs` بیندازید. همیشه از داوطلبان جدید استقبال می‌شود!"
5248

53-
#: ../../about.rst:21
5449
msgid "Many thanks go to:"
5550
msgstr "سپاس بسیار از:"
5651

57-
#: ../../about.rst:23
5852
msgid ""
5953
"Fred L. Drake, Jr., the creator of the original Python documentation toolset "
6054
"and author of much of the content;"
6155
msgstr ""
6256
"فرد ال. درک جونیور خالق مجموعه ابزارهای اصلی مستندات پایتون و نویسنده بسیاری "
6357
"از محتواها:"
6458

65-
#: ../../about.rst:25
6659
msgid ""
6760
"the `Docutils <https://docutils.sourceforge.io/>`_ project for creating "
6861
"reStructuredText and the Docutils suite;"
6962
msgstr ""
7063
"پروژه `Docutils <https://docutils.sourceforge.io/>`_ برای ایجاد "
7164
"reStructuredText و مجموعهٔ Docutils؛"
7265

73-
#: ../../about.rst:27
7466
msgid ""
7567
"Fredrik Lundh for his Alternative Python Reference project from which Sphinx "
7668
"got many good ideas."
7769
msgstr ""
78-
"فردریک لوند (Fredrik Lundh) برای پروژه‌ی \"Alternative Python Reference\" "
79-
"(مرجع جایگزین پایتون) که از آن بسیاری از ایده‌های خوب برای Sphinx (اسفینکس) "
80-
"گرفته شد."
70+
"فردریک لوند (Fredrik Lundh) برای پروژه‌ی \"Alternative Python "
71+
"Reference\" (مرجع جایگزین پایتون) که از آن بسیاری از ایده‌های خوب برای Sphinx "
72+
"(اسفینکس) گرفته شد."
8173

82-
#: ../../about.rst:32
8374
msgid "Contributors to the Python documentation"
8475
msgstr "مشارکت کنندگان مستندات پایتون"
8576

86-
#: ../../about.rst:34
8777
msgid ""
8878
"Many people have contributed to the Python language, the Python standard "
8979
"library, and the Python documentation. See :source:`Misc/ACKS` in the "
9080
"Python source distribution for a partial list of contributors."
9181
msgstr ""
9282
"افراد زیادی در توسعه زبان پایتون، کتابخانه استاندارد پایتون، و مستندات "
93-
"پایتون مشارکت داشته‌اند. برای مشاهده فهرستی از برخی از این مشارکت‌کنندگان، "
94-
"به :source:`Misc/ACKS` در توزیع سورس پایتون مراجعه کنید."
83+
"پایتون مشارکت داشته‌اند. برای مشاهده فهرستی از برخی از این مشارکت‌کنندگان، به :"
84+
"source:`Misc/ACKS` در توزیع سورس پایتون مراجعه کنید."
9585

96-
#: ../../about.rst:38
9786
msgid ""
9887
"It is only with the input and contributions of the Python community that "
9988
"Python has such wonderful documentation -- Thank You!"

0 commit comments

Comments
 (0)