From bf4d9bd9ed89821e69dfad2d6d3ef297a9c55684 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Wed, 19 Oct 2022 07:45:29 -0300 Subject: [PATCH 1/7] Use new Transifex CLI tool The Python implementation named transifex-client uses Transifex's APIv2, which is deprecated and will sunset in november 2022. The new tool, called Transifex CLI, is written in Golang and is APIv3-ready. So adjusting the CI and requirements.txt is required. --- .github/workflows/update.yml | 4 ++++ requirements.txt | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 0ed605d5f..84d51b3d9 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -35,6 +35,10 @@ jobs: uses: actions/setup-python@v2 with: python-version: '3.9' + - name: Install Transifex CLI + run: | + curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash + mv tx /usr/local/bin/tx - name: Install dependencies run: | sudo apt update -y && sudo apt install gettext -y diff --git a/requirements.txt b/requirements.txt index 9925315c1..e5c1edef9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -transifex-client sphinx sphinx-intl powrap From c7bcef2edde87e6ead8e189a56b73a8d1653d5bb Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Wed, 19 Oct 2022 08:40:25 -0300 Subject: [PATCH 2/7] Fix condition in the merge job Having the proper condition is important to have the translation update in the latest Python version (python-newest project), and the condition wouldn't match the current repository. --- .github/workflows/update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 84d51b3d9..4d298399a 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -107,7 +107,7 @@ jobs: run: | powrap --modified -C ${{ matrix.branch }} - name: Commit and push changes - if: github.repository == 'rffontenelle/python-docs-pt-br' + if: github.repository == 'python/python-docs-ja' run: | cd ${{ matrix.branch }} git config user.name github-actions From 8e9d13d71f76a95030362ff1a5af6c8766348790 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Thu, 20 Oct 2022 09:56:01 -0300 Subject: [PATCH 3/7] Set a working-directory to install tx tool To avoid having LICENSE in checkout directory Co-authored-by: Maciej Olko --- .github/workflows/update.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 4d298399a..19c1521b3 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -38,7 +38,7 @@ jobs: - name: Install Transifex CLI run: | curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash - mv tx /usr/local/bin/tx + working-directory: /usr/local/bin - name: Install dependencies run: | sudo apt update -y && sudo apt install gettext -y From 88bf92a5374e0c7e7041cdc1c340f0a94337552d Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Mon, 24 Oct 2022 13:51:11 -0300 Subject: [PATCH 4/7] Update sphinx-intl required version Last released sphinx-intl uses old transifex-client, which uses the deprecated Transifex APIv2. There is a fix committed, but it is unreleased. So using specific commit where new Transifex CLI tool works. --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index e5c1edef9..2c07cc170 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ sphinx -sphinx-intl +git+https://github.com/sphinx-doc/sphinx-intl@6b3913fea5a8c9b819818b9b28b6d0d0b6f022b3 powrap pospell pomerge From 5a0df7999a33ee138ee460f44771be702ea3692f Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Mon, 24 Oct 2022 13:53:41 -0300 Subject: [PATCH 5/7] Update script to work with the new TX command Previous solution of patching .tx/config does not work with the new client, so the script had to be updated with new solution. Now, translations are pulled into a sub-directory of cpython, and then installed in the languages's repository. Also using 'realpath' tool in ROOTDIR to retrieve absolute path, which actually eases referencing the repository root directory. --- scripts/update.sh | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/scripts/update.sh b/scripts/update.sh index e076fe0e1..7672786fb 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -7,9 +7,9 @@ set -e # Allow language being passed as 1st argument, defaults to ja LANGUAGE=${1:-ja} -ROOTDIR=$(dirname $0)/.. +ROOTDIR=$(realpath "$(dirname $0)/..") -cd ${ROOTDIR} +cd "${ROOTDIR}" if ! test -f cpython/Doc/conf.py; then echo Unable to find proper CPython Doc folder @@ -21,22 +21,19 @@ cd cpython/Doc sphinx-build -E -b gettext -D gettext_compact=0 -d build/.doctrees . locales/pot # Update CPython's .tx/config -cd locales +cd locales sphinx-intl create-txconfig -sphinx-intl update-txconfig-resources -p pot -d . --transifex-project-name python-newest +sphinx-intl update-txconfig-resources -p pot -d . --transifex-organization-name python-doc --transifex-project-name python-newest -if [ "$CI" = true ] -then +if [ "$CI" = true ]; then tx push --source --no-interactive --skip fi -# Update the translation project's .tx/config -cd ../../.. # back to $ROOTDIR -mkdir -p .tx -sed cpython/Doc/locales/.tx/config \ - -e '/^source_file/d' \ - -e 's|/LC_MESSAGES/||' \ - -e "s|^file_filter|trans.${LANGUAGE}|" \ - > .tx/config +# Pull translations into cpython/Doc/locales/LANGUAGE/LC_MESSAGES/ +tx pull -l ${LANGUAGE} -t --use-git-timestamps -f -tx pull -l ${LANGUAGE} --use-git-timestamps --parallel +# Finally, move downloaded translation files to the language's repository +cd "${LANGUAGE}/LC_MESSAGES/" +for po in $(find . -type f -name '*.po' | sort | sed 's|^\./||'); do + install -Dm644 ${po} "${ROOTDIR}/${po}" +done From d3230e5e923232f7b55f8341ebbc0ba89f3d65d2 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Mon, 24 Oct 2022 14:01:16 -0300 Subject: [PATCH 6/7] Update actions versions One of the reason is that some of them use node.js 12, which is now deprecated. Actions is displaying warnings about it. v4 of setup-python is particular useful because it introduces package caching, which reduces the time of workflow run. --- .github/workflows/update.yml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 19c1521b3..b6edb0e92 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -23,18 +23,20 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out ${{ github.repository }} - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Check out CPython - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: repository: python/cpython persist-credentials: false ref: ${{ env.CPYTHON_BRANCH }} path: cpython - name: Set up Python 3.9 - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.9' + cache: 'pip' + cache-dependency-path: '**/requirements*.txt' - name: Install Transifex CLI run: | curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash @@ -83,14 +85,20 @@ jobs: run: echo "CURRENT_BRANCH=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV - name: Check out source branch (${{ env.CURRENT_BRANCH }}) - uses: actions/checkout@v1 + uses: actions/checkout@v3 with: path: ${{ env.CURRENT_BRANCH }} - name: Check out target branch (${{ matrix.branch }}) - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: ref: ${{ matrix.branch }} path: ${{ matrix.branch }} + - name: Set up Python 3.9 + uses: actions/setup-python@v4 + with: + python-version: '3.9' + cache: 'pip' + cache-dependency-path: '**/requirements*.txt' - name: Install dependencies run: | sudo apt update -y && sudo apt install gettext -y From cec744f9c23b4224a06985122b9fb062b057a303 Mon Sep 17 00:00:00 2001 From: Rafael Fontenelle Date: Sat, 12 Nov 2022 07:57:47 -0300 Subject: [PATCH 7/7] Disable pushing translations Source files auto-update is now done elsewhere --- scripts/update.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/scripts/update.sh b/scripts/update.sh index 7672786fb..ccc0c7c65 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -25,12 +25,8 @@ cd locales sphinx-intl create-txconfig sphinx-intl update-txconfig-resources -p pot -d . --transifex-organization-name python-doc --transifex-project-name python-newest -if [ "$CI" = true ]; then - tx push --source --no-interactive --skip -fi - # Pull translations into cpython/Doc/locales/LANGUAGE/LC_MESSAGES/ -tx pull -l ${LANGUAGE} -t --use-git-timestamps -f +tx pull -l ${LANGUAGE} -t --use-git-timestamps # Finally, move downloaded translation files to the language's repository cd "${LANGUAGE}/LC_MESSAGES/"