From a464c5f080a05f0f071a2af015a6b4db56645bc2 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 17 Oct 2024 20:59:49 -0300 Subject: [PATCH 1/5] Rename locale_dirs to locales --- scripts/commit.sh | 2 +- scripts/generate_templates.sh | 4 ++-- scripts/lint.sh | 4 ++-- scripts/potodo.sh | 2 +- scripts/pull_translations.sh | 2 +- scripts/setup.sh | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/commit.sh b/scripts/commit.sh index 0b0c6cf3e..5661dfaea 100755 --- a/scripts/commit.sh +++ b/scripts/commit.sh @@ -5,7 +5,7 @@ set -eu -cd $(dirname $0)/../cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES +cd $(dirname $0)/../cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES extra_files=".tx/config stats.json potodo.md" diff --git a/scripts/generate_templates.sh b/scripts/generate_templates.sh index 3db47ef8c..d1878f411 100755 --- a/scripts/generate_templates.sh +++ b/scripts/generate_templates.sh @@ -14,8 +14,8 @@ set -xeu test -n ${PYDOC_TX_PROJECT+x} test -n ${PYDOC_LANGUAGE+x} -# Make sure to run all commands from CPython docs locale directory -cd $(dirname $0)/../cpython/Doc/locale +# Make sure to run all commands from CPython docs locales directory +cd $(dirname $0)/../cpython/Doc/locales # Generate message catalog template (.pot) files # TODO: use `make -C .. gettext` when there are only Python >= 3.12 diff --git a/scripts/lint.sh b/scripts/lint.sh index 27ddfdbb9..fdfbf3479 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -26,9 +26,9 @@ sed -i "/^\s*'literal-block',/s/ '/ #'/" conf.py opts='-E -b gettext -q -D gettext_compact=0 -d build/.doctrees . build/gettext' make build ALLSPHINXOPTS="$opts" # Update translation files with latest POT -sphinx-intl update -d locale -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null +sphinx-intl update -p build/gettext -l ${PYDOC_LANGUAGE} > /dev/null -cd locale/${PYDOC_LANGUAGE}/LC_MESSAGES +cd locales/${PYDOC_LANGUAGE}/LC_MESSAGES sphinx-lint 2> $(realpath "$rootdir/logs/sphinxlint.txt") # Undo changes to undo literal blocks disabling diff --git a/scripts/potodo.sh b/scripts/potodo.sh index 5b1cc9f05..b7e61802d 100755 --- a/scripts/potodo.sh +++ b/scripts/potodo.sh @@ -11,7 +11,7 @@ test -n ${PYDOC_LANGUAGE+x} rootdir=$(realpath $(dirname $0)/..) -cd "$rootdir"/cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES +cd "$rootdir"/cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES potodo --no-cache > potodo.md diff --git a/scripts/pull_translations.sh b/scripts/pull_translations.sh index ad38e038b..565046c90 100755 --- a/scripts/pull_translations.sh +++ b/scripts/pull_translations.sh @@ -21,7 +21,7 @@ set -xeu test -n ${PYDOC_TX_PROJECT+x} -cd "$(dirname $0)/../cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES/" +cd "$(dirname $0)/../cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES/" # If a PO file is provided as input, convert it into Transifex resource # and add it be pulled (instead of pulling all translations files). diff --git a/scripts/setup.sh b/scripts/setup.sh index 979215d5d..0c5a95adf 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -19,7 +19,7 @@ rm -rf cpython # Check out needed repositories git clone --depth 1 --single-branch --branch ${PYDOC_VERSION} https://github.com/python/cpython cpython -git clone --depth 1 --single-branch --branch ${PYDOC_VERSION} ${PYDOC_REPO} cpython/Doc/locale/${PYDOC_LANGUAGE}/LC_MESSAGES +git clone --depth 1 --single-branch --branch ${PYDOC_VERSION} ${PYDOC_REPO} cpython/Doc/locales/${PYDOC_LANGUAGE}/LC_MESSAGES # Install dependencies; Require being in a VENV or in GitHub Actions set +u From 206f7765722d34900c5822890e22caedb615ee8d Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 17 Oct 2024 21:11:53 -0300 Subject: [PATCH 2/5] Rename locale_dirs in sync.yml --- .github/workflows/sync.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index a68577a4a..1980764e8 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -43,7 +43,7 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ env.PYDOC_VERSION }} - path: cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES + path: cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES - uses: actions/setup-python@v5 with: @@ -79,7 +79,7 @@ jobs: if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} run: | # Clean up obsolete files - find cpython/Doc/locale/$PYDOC_LANGUAGE/LC_MESSAGES -name '*.po' -exec rm {} \; + find cpython/Doc/locales/$PYDOC_LANGUAGE/LC_MESSAGES -name '*.po' -exec rm {} \; ./scripts/pull_translations.sh env: TX_TOKEN: ${{ secrets.TX_TOKEN }} @@ -87,14 +87,14 @@ jobs: - name: powrap if: steps.pull.outcome == 'success' run: | - cd cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES + cd cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES powrap *.po **/*.po - name: Update statistics if: always() && inputs.secrets.TX_TOKEN != 0 run: | - python ./scripts/tx_stats.py > cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/stats.json - git -C cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/ diff stats.json + python ./scripts/tx_stats.py > cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/stats.json + git -C cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/ diff stats.json env: TX_TOKEN: ${{ secrets.TX_TOKEN }} @@ -102,7 +102,7 @@ jobs: if: always() run: | ./scripts/potodo.sh - git diff cpython/Doc/locale/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/potodo.md + git diff cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/potodo.md # 4- Commit and push translations @@ -112,7 +112,7 @@ jobs: - name: Push if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} run: | - cd cpython/Doc/locale/${{ env.PYDOC_LANGUAGE}}/LC_MESSAGES + cd cpython/Doc/locales/${{ env.PYDOC_LANGUAGE}}/LC_MESSAGES git push From 262511b1a915498643c7bf7cfb9b82cf2242633a Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 17 Oct 2024 21:17:03 -0300 Subject: [PATCH 3/5] Make translation files dir reusable in sync.yml --- .github/workflows/sync.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 1980764e8..91ba59720 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -21,6 +21,8 @@ env: PYDOC_TX_PROJECT: ${{ inputs.tx_project }} PYDOC_VERSION: ${{ inputs.version }} TX_CLI_VERSION: '1.6.16' + LANGUAGE_DIR: cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES + jobs: sync: @@ -43,7 +45,7 @@ jobs: uses: actions/checkout@v4 with: ref: ${{ env.PYDOC_VERSION }} - path: cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES + path: ${{ env.LANGUAGE_DIR }} - uses: actions/setup-python@v5 with: @@ -79,7 +81,7 @@ jobs: if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} run: | # Clean up obsolete files - find cpython/Doc/locales/$PYDOC_LANGUAGE/LC_MESSAGES -name '*.po' -exec rm {} \; + find ./${LANGUAGE_DIR} -name '*.po' -exec rm {} \; ./scripts/pull_translations.sh env: TX_TOKEN: ${{ secrets.TX_TOKEN }} @@ -87,14 +89,14 @@ jobs: - name: powrap if: steps.pull.outcome == 'success' run: | - cd cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES + cd ./${LANGUAGE_DIR} powrap *.po **/*.po - name: Update statistics if: always() && inputs.secrets.TX_TOKEN != 0 run: | - python ./scripts/tx_stats.py > cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/stats.json - git -C cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/ diff stats.json + python ./scripts/tx_stats.py > ./${LANGUAGE_DIR}/stats.json + git -C ./${LANGUAGE_DIR} diff stats.json env: TX_TOKEN: ${{ secrets.TX_TOKEN }} @@ -102,7 +104,7 @@ jobs: if: always() run: | ./scripts/potodo.sh - git diff cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES/potodo.md + git diff ./${LANGUAGE_DIR}/potodo.md # 4- Commit and push translations @@ -112,7 +114,7 @@ jobs: - name: Push if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} run: | - cd cpython/Doc/locales/${{ env.PYDOC_LANGUAGE}}/LC_MESSAGES + cd ./${LANGUAGE_DIR} git push From 90566b43bc3299994d40fd3446b0e10e4eb8888d Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 17 Oct 2024 21:22:43 -0300 Subject: [PATCH 4/5] Fix reusability of language dir variable in sync.yml --- .github/workflows/sync.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 91ba59720..166b60a8d 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -21,8 +21,6 @@ env: PYDOC_TX_PROJECT: ${{ inputs.tx_project }} PYDOC_VERSION: ${{ inputs.version }} TX_CLI_VERSION: '1.6.16' - LANGUAGE_DIR: cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES - jobs: sync: @@ -40,6 +38,10 @@ jobs: repository: 'python/cpython' ref: ${{ env.PYDOC_VERSION }} path: cpython + + - name: Set language dir variable + run: + echo "LANGUAGE_DIR=cpython/Doc/locales/$PYDOC_LANGUAGE/LC_MESSAGES" >> $GITHUB_ENV - name: Checkout this repository ${{ env.PYDOC_VERSION }} uses: actions/checkout@v4 From d12be1d3e238684b7c70d02acc4d7e5f1f3d290b Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 17 Oct 2024 21:29:20 -0300 Subject: [PATCH 5/5] Use other way to call environment varaible in sync.yml To print its value in the output --- .github/workflows/sync.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml index 166b60a8d..ad6abebd9 100644 --- a/.github/workflows/sync.yml +++ b/.github/workflows/sync.yml @@ -41,7 +41,7 @@ jobs: - name: Set language dir variable run: - echo "LANGUAGE_DIR=cpython/Doc/locales/$PYDOC_LANGUAGE/LC_MESSAGES" >> $GITHUB_ENV + echo "LANGUAGE_DIR=cpython/Doc/locales/${{ env.PYDOC_LANGUAGE }}/LC_MESSAGES" >> $GITHUB_ENV - name: Checkout this repository ${{ env.PYDOC_VERSION }} uses: actions/checkout@v4 @@ -83,7 +83,7 @@ jobs: if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} run: | # Clean up obsolete files - find ./${LANGUAGE_DIR} -name '*.po' -exec rm {} \; + find ./${{ env.LANGUAGE_DIR }} -name '*.po' -exec rm {} \; ./scripts/pull_translations.sh env: TX_TOKEN: ${{ secrets.TX_TOKEN }} @@ -91,14 +91,14 @@ jobs: - name: powrap if: steps.pull.outcome == 'success' run: | - cd ./${LANGUAGE_DIR} + cd ./${{ env.LANGUAGE_DIR }} powrap *.po **/*.po - name: Update statistics if: always() && inputs.secrets.TX_TOKEN != 0 run: | - python ./scripts/tx_stats.py > ./${LANGUAGE_DIR}/stats.json - git -C ./${LANGUAGE_DIR} diff stats.json + python ./scripts/tx_stats.py > ./${{ env.LANGUAGE_DIR }}/stats.json + git -C ./${{ env.LANGUAGE_DIR }} diff stats.json env: TX_TOKEN: ${{ secrets.TX_TOKEN }} @@ -106,7 +106,7 @@ jobs: if: always() run: | ./scripts/potodo.sh - git diff ./${LANGUAGE_DIR}/potodo.md + git diff ./${{ env.LANGUAGE_DIR }}/potodo.md # 4- Commit and push translations @@ -116,7 +116,7 @@ jobs: - name: Push if: ${{ contains(fromJSON('["schedule", "workflow_dispatch"]'), github.event_name) }} run: | - cd ./${LANGUAGE_DIR} + cd ./${{ env.LANGUAGE_DIR }} git push