Skip to content

Commit 3c5bab0

Browse files
authored
Rename locale_dirs to locales (#235)
* Rename locale_dirs to locales * Rename locale_dirs in sync.yml * Make translation files dir reusable in sync.yml * Fix reusability of language dir variable in sync.yml * Use other way to call environment varaible in sync.yml To print its value in the output
1 parent 68de5ca commit 3c5bab0

File tree

7 files changed

+19
-15
lines changed

7 files changed

+19
-15
lines changed

.github/workflows/sync.yml

+11-7
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ jobs:
3838
repository: 'python/cpython'
3939
ref: ${{ env.PYDOC_VERSION }}
4040
path: cpython
41+
42+
- name: Set language dir variable
43+
run:
44+
echo "LANGUAGE_DIR=cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES" >> $GITHUB_ENV
4145

4246
- name: Checkout this repository ${{ env.PYDOC_VERSION }}
4347
uses: actions/checkout@v4
4448
with:
4549
ref: ${{ env.PYDOC_VERSION }}
46-
path: cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES
50+
path: ${{ env.LANGUAGE_DIR }}
4751

4852
- uses: actions/setup-python@v5
4953
with:
@@ -79,30 +83,30 @@ jobs:
7983
if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
8084
run: |
8185
# Clean up obsolete files
82-
find cpython/Doc/locale/$PYDOC_LANGUAGE/LC_MESSAGES -name '*.po' -exec rm {} \;
86+
find ./${{ env.LANGUAGE_DIR }} -name '*.po' -exec rm {} \;
8387
./scripts/pull_translations.sh
8488
env:
8589
TX_TOKEN: ${{ secrets.TX_TOKEN }}
8690

8791
- name: powrap
8892
if: steps.pull.outcome == 'success'
8993
run: |
90-
cd cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES
94+
cd ./${{ env.LANGUAGE_DIR }}
9195
powrap *.po **/*.po
9296
9397
- name: Update statistics
9498
if: always() && inputs.secrets.TX_TOKEN != 0
9599
run: |
96-
python ./scripts/tx_stats.py > cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/stats.json
97-
git -C cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/ diff stats.json
100+
python ./scripts/tx_stats.py > ./${{ env.LANGUAGE_DIR }}/stats.json
101+
git -C ./${{ env.LANGUAGE_DIR }} diff stats.json
98102
env:
99103
TX_TOKEN: ${{ secrets.TX_TOKEN }}
100104

101105
- name: Update potodo.md
102106
if: always()
103107
run: |
104108
./scripts/potodo.sh
105-
git diff cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/potodo.md
109+
git diff ./${{ env.LANGUAGE_DIR }}/potodo.md
106110
107111
# 4- Commit and push translations
108112

@@ -112,7 +116,7 @@ jobs:
112116
- name: Push
113117
if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }}
114118
run: |
115-
cd cpython/Doc/locale/${{ env.PYDOC_LANGUAGE}}/LC_MESSAGES
119+
cd ./${{ env.LANGUAGE_DIR }}
116120
git push
117121
118122

scripts/commit.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
set -eu
77

8-
cd $(dirname $0)/../cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES
8+
cd $(dirname $0)/../cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES
99

1010
extra_files=".tx/config stats.json potodo.md"
1111

scripts/generate_templates.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ set -xeu
1414
test -n ${PYDOC_TX_PROJECT+x}
1515
test -n ${PYDOC_LANGUAGE+x}
1616

17-
# Make sure to run all commands from CPython docs locale directory
18-
cd $(dirname $0)/../cpython/Doc/locale
17+
# Make sure to run all commands from CPython docs locales directory
18+
cd $(dirname $0)/../cpython/Doc/locales
1919

2020
# Generate message catalog template (.pot) files
2121
# TODO: use `make -C .. gettext` when there are only Python >= 3.12

scripts/lint.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py
2626
opts='-E -b gettext -q -D gettext_compact=0 -d build/.doctrees . build/gettext'
2727
make build ALLSPHINXOPTS="$opts"
2828
# Update translation files with latest POT
29-
sphinx-intl update -d locale -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null
29+
sphinx-intl update -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null
3030

31-
cd locale/${PYDOC_LANGUAGE}/LC_MESSAGES
31+
cd locales/${PYDOC_LANGUAGE}/LC_MESSAGES
3232
sphinx-lint 2> $(realpath "$rootdir/logs/sphinxlint.txt")
3333

3434
# Undo changes to undo literal blocks disabling

scripts/potodo.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test -n ${PYDOC_LANGUAGE+x}
1111

1212
rootdir=$(realpath $(dirname $0)/..)
1313

14-
cd "$rootdir"/cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES
14+
cd "$rootdir"/cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES
1515

1616
potodo --no-cache > potodo.md
1717

scripts/pull_translations.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ set -xeu
2121

2222
test -n ${PYDOC_TX_PROJECT+x}
2323

24-
cd "$(dirname $0)/../cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES/"
24+
cd "$(dirname $0)/../cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES/"
2525

2626
# If a PO file is provided as input, convert it into Transifex resource
2727
# and add it be pulled (instead of pulling all translations files).

scripts/setup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ rm -rf cpython
1919

2020
# Check out needed repositories
2121
git clone --depth 1 --single-branch --branch ${PYDOC_VERSION} https://github.com/python/cpython cpython
22-
git clone --depth 1 --single-branch --branch ${PYDOC_VERSION} ${PYDOC_REPO} cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES
22+
git clone --depth 1 --single-branch --branch ${PYDOC_VERSION} ${PYDOC_REPO} cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES
2323

2424
# Install dependencies; Require being in a VENV or in GitHub Actions
2525
set +u

0 commit comments

Comments
 (0)