diff --git a/.github/workflows/update.yml b/.github/workflows/update.yml index 0ed605d5f..b6edb0e92 100644 --- a/.github/workflows/update.yml +++ b/.github/workflows/update.yml @@ -23,18 +23,24 @@ 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 + working-directory: /usr/local/bin - name: Install dependencies run: | sudo apt update -y && sudo apt install gettext -y @@ -79,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 @@ -103,7 +115,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 diff --git a/requirements.txt b/requirements.txt index 9925315c1..2c07cc170 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ -transifex-client sphinx -sphinx-intl +git+https://github.com/sphinx-doc/sphinx-intl@6b3913fea5a8c9b819818b9b28b6d0d0b6f022b3 powrap pospell pomerge diff --git a/scripts/update.sh b/scripts/update.sh index e076fe0e1..ccc0c7c65 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,15 @@ 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 - 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 -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